From dc7a3e2a29c5392e96fc1160d34f119e880325ae Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Mon, 1 Jun 2026 20:35:06 +0100 Subject: [PATCH] feat(update): add interactive confirmation prompt to nomarchy-update and expose in all themes --- docs/SCRIPTS.md | 6 +-- .../waybar/themes/summer-day/config.jsonc | 11 ++++- features/scripts/utils/nomarchy-update | 44 +++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/docs/SCRIPTS.md b/docs/SCRIPTS.md index cf25afd..33ca37c 100644 --- a/docs/SCRIPTS.md +++ b/docs/SCRIPTS.md @@ -78,7 +78,7 @@ Phase B (per-batch PRs) refines those into `port-from-omarchy`, | `nomarchy-launch-bluetooth` | `features/scripts/utils` | core/home/config/nomarchy/default/hypr/bindings/utilities.conf,features/desktop/waybar/config/config.jsonc, +1 more | `kept` | | | `nomarchy-launch-browser` | `features/scripts/utils` | core/home/config/nomarchy-skill/SKILL.md,features/desktop/hyprland/config/bindings.conf | `kept` | | | `nomarchy-launch-editor` | `features/scripts/utils` | features/desktop/hyprland/config/bindings.conf,features/scripts/utils/nomarchy-menu, +1 more | `kept` | | -| `nomarchy-launch-floating-terminal-with-presentation` | `features/scripts/utils` | core/home/config/nomarchy/default/mako/core.ini,features/desktop/waybar/config/config.jsonc, +3 more | `kept` | | +| `nomarchy-launch-floating-terminal-with-presentation` | `features/scripts/utils` | core/home/config/nomarchy/default/mako/core.ini,features/desktop/waybar/config/config.jsonc, +4 more | `kept` | | | `nomarchy-launch-or-focus` | `features/scripts/utils` | core/home/config/nomarchy/extensions/menu.sh,features/desktop/hyprland/config/bindings.conf, +8 more | `kept` | | | `nomarchy-launch-or-focus-tui` | `features/scripts/utils` | core/home/config/nomarchy/extensions/menu.sh,features/desktop/waybar/config/config.jsonc, +5 more | `kept` | | | `nomarchy-launch-or-focus-webapp` | `features/scripts/utils` | features/desktop/hyprland/config/bindings.conf | `kept` | | @@ -169,8 +169,8 @@ Phase B (per-batch PRs) refines those into `port-from-omarchy`, | `nomarchy-tui-remove` | `features/scripts/utils` | core/home/config/nomarchy-skill/SKILL.md | `kept` | | | `nomarchy-tui-remove-all` | `features/scripts/utils` | core/home/config/nomarchy-skill/SKILL.md | `kept` | | | `nomarchy-tz-select` | `core/system/scripts` | features/desktop/waybar/config/config.jsonc,features/scripts/utils/nomarchy-menu, +2 more | `kept` | | -| `nomarchy-update` | `core/system/scripts` | core/home/config/nomarchy-skill/SKILL.md,core/home/config/nomarchy/default/mako/core.ini, +4 more | `kept` | | -| `nomarchy-update-available` | `features/scripts/utils` | features/desktop/waybar/config/config.jsonc,features/desktop/waybar/themes/summer-night/config.jsonc | `kept` | | +| `nomarchy-update` | `core/system/scripts` | core/home/config/nomarchy-skill/SKILL.md,core/home/config/nomarchy/default/mako/core.ini, +5 more | `kept` | | +| `nomarchy-update-available` | `features/scripts/utils` | features/desktop/waybar/config/config.jsonc,features/desktop/waybar/themes/summer-day/config.jsonc, +1 more | `kept` | | | `nomarchy-update-firmware` | `features/scripts/utils` | features/scripts/utils/nomarchy-menu | `kept` | | | `nomarchy-update-time` | `core/system/scripts` | features/scripts/utils/nomarchy-menu | `kept` | | | `nomarchy-upload-log` | `features/scripts/utils` | core/home/config/nomarchy-skill/SKILL.md,features/scripts/utils/nomarchy-debug | `kept` | | diff --git a/features/desktop/waybar/themes/summer-day/config.jsonc b/features/desktop/waybar/themes/summer-day/config.jsonc index a4677de..47cd663 100755 --- a/features/desktop/waybar/themes/summer-day/config.jsonc +++ b/features/desktop/waybar/themes/summer-day/config.jsonc @@ -10,7 +10,7 @@ "spacing": 15, "modules-left": ["custom/launcher", "clock", "clock#date"], "modules-center": ["wlr/workspaces"], - "modules-right": ["pulseaudio", "network", "battery", "custom/powermenu"], + "modules-right": ["custom/update", "pulseaudio", "network", "battery", "custom/powermenu"], "wlr/workspaces": { "disable-scroll": true, @@ -39,6 +39,15 @@ "tooltip-format": "Nomarchy Menu\n\nSuper + Shift + Space" }, + "custom/update": { + "format": "", + "exec": "nomarchy-update-available", + "on-click": "nomarchy-launch-floating-terminal-with-presentation nomarchy-update", + "tooltip-format": "Nomarchy update available", + "signal": 7, + "interval": 21600 + }, + "backlight": { "max-length": "4", "format": "{icon}", diff --git a/features/scripts/utils/nomarchy-update b/features/scripts/utils/nomarchy-update index fec05fe..c74552f 100755 --- a/features/scripts/utils/nomarchy-update +++ b/features/scripts/utils/nomarchy-update @@ -7,6 +7,17 @@ set -e +# Fast fail offline check for gum +if ! ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1; then + if command -v gum >/dev/null 2>&1; then + gum style --foreground 196 "You are offline. Cannot update." + sleep 3 + else + echo "You are offline. Cannot update." + fi + exit 1 +fi + # Detect the repository location if [ -f "/etc/nixos/flake.nix" ]; then REPO_DIR="/etc/nixos" @@ -17,6 +28,33 @@ else exit 1 fi +CURRENT_REV=$(jq -r '.nodes.nomarchy.locked.rev // empty' "$REPO_DIR/flake.lock" 2>/dev/null) +REMOTE_URL="https://git.bemagri.xyz/bernardo/Nomarchy.git" +LATEST_REV=$(git ls-remote "$REMOTE_URL" HEAD 2>/dev/null | awk '{print $1}') + +if command -v gum >/dev/null 2>&1; then + gum style --foreground 212 --border double --margin "1 2" --padding "1 2" "Nomarchy System Update" + + if [[ "$CURRENT_REV" != "$LATEST_REV" && -n "$LATEST_REV" ]]; then + echo -e "An update for Nomarchy is available!\n" + echo -e "Current Revision: ${CURRENT_REV:0:7}" + echo -e "Latest Revision: ${LATEST_REV:0:7}\n" + + if ! gum confirm "Do you want to download and apply the update now?"; then + echo "Update cancelled." + sleep 2 + exit 0 + fi + else + echo -e "\nYou are already up to date! (${CURRENT_REV:0:7})" + if ! gum confirm "Do you want to force a system rebuild anyway?"; then + echo "Cancelled." + sleep 2 + exit 0 + fi + fi +fi + echo "--- Starting Nomarchy Full Update ---" # 1. Unpin the flake if it's currently pinned to the install commit @@ -33,3 +71,9 @@ sudo nix --extra-experimental-features 'nix-command flakes' flake update --flake nomarchy-sys-update echo "--- Nomarchy Full Update Complete ---" +if command -v gum >/dev/null 2>&1; then + echo "" + gum style --foreground 82 "Update Applied Successfully!" + echo "Press any key to exit." + read -n 1 -s -r +fi