From f593cc19339c76c4df616fb01d3f33f28d9819c8 Mon Sep 17 00:00:00 2001 From: Felitendo Date: Sat, 8 Aug 2026 15:05:38 +0200 Subject: [PATCH] Menu: flip the switches without asking for a keypress Toggling automatic updates or notifications returned to a 'press any key' prompt for no reason - the status block at the top of the menu already shows the new state. cau_bad and cau_note now flag that they printed something, so the acknowledgement only appears when there is genuinely something to read (a failed sudoers check, a missing AUR helper) instead of after every toggle. --- Makefile | 2 +- src/lib/common.sh | 11 +++++++++-- src/lib/menu.sh | 9 +++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2567a4c..aa4774b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ # Overridable so a packager can pass the version it is actually building # (`make VERSION=$pkgver`). The literal below is the fallback for builds # straight from a checkout, and is what a release tag has to carry. -VERSION ?= 1.0.3 +VERSION ?= 1.0.4 PREFIX ?= /usr DESTDIR ?= diff --git a/src/lib/common.sh b/src/lib/common.sh index 8921d62..2e00bb8 100644 --- a/src/lib/common.sh +++ b/src/lib/common.sh @@ -146,11 +146,18 @@ cau_run_logged() { # Terminal helpers for the CLI # --------------------------------------------------------------------------- +# Set by cau_bad and cau_note. The menu redraws immediately after an action, +# which would wipe the screen; this marks that something was printed that the +# user still has to read, so only those cases wait for a keypress. A plain +# success needs no acknowledgement - the status block at the top of the menu +# already shows the new state. +CAU_UI_NEEDS_ACK='' + cau_say() { printf '%s\n' "$*"; } cau_head() { printf '\n%s%s%s\n\n' "$CAU_C_BOLD$CAU_C_BLUE" "$*" "$CAU_C_RESET"; } cau_ok() { printf '%s✔%s %s\n' "$CAU_C_GREEN" "$CAU_C_RESET" "$*"; } -cau_bad() { printf '%s✘%s %s\n' "$CAU_C_RED" "$CAU_C_RESET" "$*" >&2; } -cau_note() { printf '%s•%s %s\n' "$CAU_C_DIM" "$CAU_C_RESET" "$*"; } +cau_bad() { CAU_UI_NEEDS_ACK=1; printf '%s✘%s %s\n' "$CAU_C_RED" "$CAU_C_RESET" "$*" >&2; } +cau_note() { CAU_UI_NEEDS_ACK=1; printf '%s•%s %s\n' "$CAU_C_DIM" "$CAU_C_RESET" "$*"; } # --------------------------------------------------------------------------- # State files diff --git a/src/lib/menu.sh b/src/lib/menu.sh index 55c5337..bbb47c2 100644 --- a/src/lib/menu.sh +++ b/src/lib/menu.sh @@ -152,17 +152,22 @@ cau_ui_menu() { printf '%s\n' "$choice" case "$choice" in + # The two switches flip and return straight to the menu, where the + # status block shows the result. Only a warning or an error holds + # the screen (see CAU_UI_NEEDS_ACK). 1) + CAU_UI_NEEDS_ACK='' if [[ $CFG_ENABLED == yes ]]; then cau_do_disable; else cau_do_enable; fi - cau_pause + if [[ -n $CAU_UI_NEEDS_ACK ]]; then cau_pause; fi ;; 2) + CAU_UI_NEEDS_ACK='' if [[ $CFG_NOTIFICATIONS == yes ]]; then cau_do_notifications off else cau_do_notifications on fi - cau_pause + if [[ -n $CAU_UI_NEEDS_ACK ]]; then cau_pause; fi ;; 3) cau_do_run --force; cau_pause ;; 4) cau_do_log; cau_pause ;;