Show a failure state when a presented command exits non-zero
The floating-terminal presentation wrapper showed the green "Done!" prompt for every exit code except Ctrl-C, so a failed update or channel switch closed looking like a success. Pass the command's exit code through to omarchy-show-done and render a red "Failed (exit code N)!" prompt when it is non-zero. The pkg install/remove pickers get the same treatment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f5194e3ff5
commit
bc0753dfcb
5 files changed
+15
-6
No files matched your search
@@ -8,6 +8,7 @@
|
||||
source omarchy-restart-gum
|
||||
|
||||
cmd="$*"
|
||||
presentation_script="omarchy-show-logo; $cmd; if (( \$? != 130 )); then omarchy-show-done; fi"
|
||||
# 130 is the user bailing with Ctrl-C; anything else gets the Done/Failed prompt.
|
||||
presentation_script="omarchy-show-logo; $cmd; code=\$?; if (( code != 130 )); then omarchy-show-done \$code; fi"
|
||||
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --app-id=org.omarchy.terminal --title=Omarchy -e bash -c "$presentation_script"
|
||||
@@ -24,6 +24,7 @@ if [[ -n $pkg_names ]]; then
|
||||
source omarchy-sudo-keepalive
|
||||
|
||||
echo "$pkg_names" | sed 's/^/aur\//' | tr '\n' ' ' | xargs yay -S --noconfirm
|
||||
code=$?
|
||||
sudo updatedb --prune-bind-mounts=no --add-prunepaths=/.snapshots
|
||||
omarchy-show-done
|
||||
omarchy-show-done $code
|
||||
fi
|
||||
@@ -22,5 +22,5 @@ if [[ -n $pkg_names ]]; then
|
||||
|
||||
# Convert newline-separated selections to space-separated for pacman
|
||||
echo "$pkg_names" | tr '\n' ' ' | xargs sudo pacman -S --noconfirm
|
||||
omarchy-show-done
|
||||
omarchy-show-done $?
|
||||
fi
|
||||
@@ -20,5 +20,5 @@ pkg_names=$(yay -Qqe | fzf "${fzf_args[@]}")
|
||||
if [[ -n $pkg_names ]]; then
|
||||
# Convert newline-separated selections to space-separated for yay
|
||||
echo "$pkg_names" | tr '\n' ' ' | xargs sudo pacman -Rns --noconfirm
|
||||
omarchy-show-done
|
||||
omarchy-show-done $?
|
||||
fi
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Display a "Done!" message and wait for user to press any key.
|
||||
# omarchy:summary=Display a "Done!" or "Failed!" message and wait for user to press any key.
|
||||
# omarchy:args=[exit-code]
|
||||
|
||||
code="${1:-0}"
|
||||
|
||||
# The device node is there whether or not a terminal is behind it, so opening
|
||||
# it is the only test that means anything.
|
||||
@@ -13,6 +16,10 @@ while read -rsn 1 -t 0.1 _ </dev/tty; do :; done
|
||||
|
||||
# Prompt on the terminal rather than stdout, or a caller that redirects us
|
||||
# leaves the user waiting on a prompt they were never shown.
|
||||
printf '\n\033[32m● \033[0mDone! Press any key to close...' >/dev/tty
|
||||
if (( code == 0 )); then
|
||||
printf '\n\033[32m● \033[0mDone! Press any key to close...' >/dev/tty
|
||||
else
|
||||
printf '\n\033[31m● \033[0mFailed (exit code %d)! Press any key to close...' "$code" >/dev/tty
|
||||
fi
|
||||
read -rsn 1 </dev/tty
|
||||
echo >/dev/tty
|
||||
Reference in new issue
Block a user