Compare commits

...
3 Commits
Author SHA1 Message Date
Felitendo f593cc1933 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.
2026-08-08 15:05:38 +02:00
Felitendo 20fbadbc95 Menu: act on a single keypress instead of waiting for Enter
Also stops Enter from quitting the menu (it used to share the quit branch with
q) and swallows the tail of an escape sequence, so one arrow key redraws once
rather than three times and never closes the menu.
2026-08-08 14:58:28 +02:00
Felitendo e42fb4f61c Make the reported version follow the version actually being built
VERSION is now overridable, so the PKGBUILD passes $pkgver into make and the
two can no longer disagree. v1.0.1 shipped a Makefile that still said 1.0.0, so
'cachy-auto-update --version' reported the wrong release.
2026-08-08 14:45:07 +02:00
5 changed files with 40 additions and 12 deletions

No files matched your search

+4 -1
View File
@@ -5,7 +5,10 @@
# targets degrade to a no-op when msgfmt/scdoc are missing, so the tree stays # targets degrade to a no-op when msgfmt/scdoc are missing, so the tree stays
# usable for development without the build dependencies installed. # usable for development without the build dependencies installed.
VERSION := 1.0.0 # 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.4
PREFIX ?= /usr PREFIX ?= /usr
DESTDIR ?= DESTDIR ?=
+1 -1
View File
@@ -134,7 +134,7 @@ msgstr ""
msgid "Quit" msgid "Quit"
msgstr "" msgstr ""
msgid "Press Enter to continue..." msgid "Press any key to continue..."
msgstr "" msgstr ""
#. Commands #. Commands
+2 -2
View File
@@ -135,8 +135,8 @@ msgstr "Aktuelle Bedingungen anzeigen"
msgid "Quit" msgid "Quit"
msgstr "Beenden" msgstr "Beenden"
msgid "Press Enter to continue..." msgid "Press any key to continue..."
msgstr "Zum Fortfahren Enter drücken …" msgstr "Zum Fortfahren eine Taste drücken …"
#. Commands #. Commands
msgid "Automatic updates are on." msgid "Automatic updates are on."
+9 -2
View File
@@ -146,11 +146,18 @@ cau_run_logged() {
# Terminal helpers for the CLI # 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_say() { printf '%s\n' "$*"; }
cau_head() { printf '\n%s%s%s\n\n' "$CAU_C_BOLD$CAU_C_BLUE" "$*" "$CAU_C_RESET"; } 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_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_bad() { CAU_UI_NEEDS_ACK=1; 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_note() { CAU_UI_NEEDS_ACK=1; printf '%s•%s %s\n' "$CAU_C_DIM" "$CAU_C_RESET" "$*"; }
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# State files # State files
+24 -6
View File
@@ -145,31 +145,49 @@ cau_ui_menu() {
printf ' [q] %s\n' "$(cau_msg "Quit")" printf ' [q] %s\n' "$(cau_msg "Quit")"
printf '\n > ' printf '\n > '
read -r choice || { printf '\n'; return 0; } # One keypress, no Enter. -s keeps the raw character out of the
# display so the echo below is the only thing printed, and a failing
# read means EOF (Ctrl-D, or a script piping input) - that quits.
read -rsn1 choice || { printf '\n'; return 0; }
printf '%s\n' "$choice"
case "$choice" in 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) 1)
CAU_UI_NEEDS_ACK=''
if [[ $CFG_ENABLED == yes ]]; then cau_do_disable; else cau_do_enable; fi 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) 2)
CAU_UI_NEEDS_ACK=''
if [[ $CFG_NOTIFICATIONS == yes ]]; then if [[ $CFG_NOTIFICATIONS == yes ]]; then
cau_do_notifications off cau_do_notifications off
else else
cau_do_notifications on cau_do_notifications on
fi fi
cau_pause if [[ -n $CAU_UI_NEEDS_ACK ]]; then cau_pause; fi
;; ;;
3) cau_do_run --force; cau_pause ;; 3) cau_do_run --force; cau_pause ;;
4) cau_do_log; cau_pause ;; 4) cau_do_log; cau_pause ;;
5) cau_ui_status_conditions; cau_pause ;; 5) cau_ui_status_conditions; cau_pause ;;
q|Q|'') return 0 ;; q|Q) return 0 ;;
$'\e')
# Arrow keys and friends arrive as ESC [ X. Swallow the rest so
# one keypress does not redraw the menu three times. Escape is
# deliberately not a quit key: that would make a stray arrow
# key close the menu.
read -rsn2 -t 0.05 _ 2>/dev/null || true
;;
# Anything else, Enter included, just redraws.
*) ;; *) ;;
esac esac
done done
} }
cau_pause() { cau_pause() {
printf '\n %s' "$(cau_msg "Press Enter to continue...")" printf '\n %s' "$(cau_msg "Press any key to continue...")"
read -r _ || true read -rsn1 _ || true
printf '\n'
} }