feat: show results in the menu instead of waiting for a key

This commit is contained in:
Felitendo committed 2026-09-24 10:44:52 +02:00
1 parent 472cf5382c
commit 074a654597
5 files changed
+48 -30

No files matched your search

+3
View File
@@ -94,6 +94,9 @@ msgstr "Beenden"
msgid "Press any key to continue..." msgid "Press any key to continue..."
msgstr "Beliebige Taste drücken …" msgstr "Beliebige Taste drücken …"
msgid "One moment..."
msgstr "Einen Moment …"
#. Settings #. Settings
msgid "Turn off middle-click paste" msgid "Turn off middle-click paste"
msgstr "Mittelklick-Einfügen abschalten" msgstr "Mittelklick-Einfügen abschalten"
+3
View File
@@ -94,6 +94,9 @@ msgstr ""
msgid "Press any key to continue..." msgid "Press any key to continue..."
msgstr "" msgstr ""
msgid "One moment..."
msgstr ""
#. Settings #. Settings
msgid "Turn off middle-click paste" msgid "Turn off middle-click paste"
msgstr "" msgstr ""
+2 -8
View File
@@ -215,12 +215,6 @@ else
MCA_C_GREEN='' MCA_C_YELLOW='' MCA_C_RED='' MCA_C_GREEN='' MCA_C_YELLOW='' MCA_C_RED=''
fi fi
# Set by mca_bad and mca_note. The menu redraws straight after an action, which
# would wipe the screen; this marks that something was printed the user still
# has to read. A plain success needs no acknowledgement, because the status
# block at the top of the menu already shows the new state.
MCA_UI_NEEDS_ACK=''
# --quiet silences progress chatter; errors still go to stderr. Used by the # --quiet silences progress chatter; errors still go to stderr. Used by the
# systemd unit, which has no terminal and logs to the journal anyway. # systemd unit, which has no terminal and logs to the journal anyway.
MCA_QUIET='' MCA_QUIET=''
@@ -228,8 +222,8 @@ MCA_QUIET=''
mca_say() { [[ -n $MCA_QUIET ]] || printf '%s\n' "$*"; } mca_say() { [[ -n $MCA_QUIET ]] || printf '%s\n' "$*"; }
mca_head() { printf '\n%s%s%s\n\n' "$MCA_C_BOLD$MCA_C_BLUE" "$*" "$MCA_C_RESET"; } mca_head() { printf '\n%s%s%s\n\n' "$MCA_C_BOLD$MCA_C_BLUE" "$*" "$MCA_C_RESET"; }
mca_ok() { [[ -n $MCA_QUIET ]] || printf '%s✔%s %s\n' "$MCA_C_GREEN" "$MCA_C_RESET" "$*"; } mca_ok() { [[ -n $MCA_QUIET ]] || printf '%s✔%s %s\n' "$MCA_C_GREEN" "$MCA_C_RESET" "$*"; }
mca_bad() { MCA_UI_NEEDS_ACK=1; printf '%s✘%s %s\n' "$MCA_C_RED" "$MCA_C_RESET" "$*" >&2; } mca_bad() { printf '%s✘%s %s\n' "$MCA_C_RED" "$MCA_C_RESET" "$*" >&2; }
mca_note() { MCA_UI_NEEDS_ACK=1; [[ -n $MCA_QUIET ]] || printf '%s•%s %s\n' "$MCA_C_DIM" "$MCA_C_RESET" "$*"; } mca_note() { [[ -n $MCA_QUIET ]] || printf '%s•%s %s\n' "$MCA_C_DIM" "$MCA_C_RESET" "$*"; }
mca_have() { command -v "$1" > /dev/null 2>&1; } mca_have() { command -v "$1" > /dev/null 2>&1; }
+34 -19
View File
@@ -31,14 +31,25 @@ mca_ui_term_restore() {
MCA_TERM_SAVED='' MCA_TERM_SAVED=''
} }
# Runs an action with the terminal handed back to normal line mode, so anything # What the last action printed. The menu shows it under the status until the
# it prints or prompts for behaves the way a program expects. # next key, so nothing has to wait for a key on a screen of its own.
mca_ui_cooked() { MCA_UI_MSG=''
mca_ui_term_restore
"$@" # Set while the menu runs. Its status block already says that running
local rc=$? # applications need a restart, so the actions leave that line out there.
mca_ui_term_raw MCA_IN_MENU=''
return $rc
# mca_ui_run <command...>
# Runs an action in this shell (so what it scans and loads stays) with its
# output kept for the menu. None of them asks anything.
mca_ui_run() {
local tmp
printf ' %s%s%s\n' "$MCA_C_DIM" "$(mca_msg "One moment...")" "$MCA_C_RESET"
tmp="$(mktemp)" || { "$@"; return; }
"$@" > "$tmp" 2>&1
MCA_UI_MSG="$(< "$tmp")"
rm -f -- "$tmp"
} }
# mca_read_key # mca_read_key
@@ -432,8 +443,7 @@ mca_ui_apps() {
count=${#MCA_IDS[@]} count=${#MCA_IDS[@]}
if (( count == 0 )); then if (( count == 0 )); then
printf '\n %s\n' "$(mca_msg "No Chromium-based applications found.")" MCA_UI_MSG="$(mca_msg "No Chromium-based applications found.")"
mca_pause
return 1 return 1
fi fi
@@ -550,8 +560,9 @@ mca_ui_apps() {
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
mca_ui_menu() { mca_ui_menu() {
local choice local choice line
MCA_IN_MENU=1
mca_ui_term_raw mca_ui_term_raw
trap 'mca_ui_term_restore' EXIT INT TERM trap 'mca_ui_term_restore' EXIT INT TERM
@@ -562,6 +573,13 @@ mca_ui_menu() {
mca_head " $MCA_PRETTY" mca_head " $MCA_PRETTY"
mca_ui_status mca_ui_status
printf '\n' printf '\n'
if [[ -n $MCA_UI_MSG ]]; then
while IFS= read -r line; do
printf ' %s\n' "$line"
done <<< "$MCA_UI_MSG"
printf '\n'
MCA_UI_MSG=''
fi
printf ' [1] %s\n' "$(mca_msg "Turn autoscroll on or off")" printf ' [1] %s\n' "$(mca_msg "Turn autoscroll on or off")"
printf ' [2] %s\n' "$(mca_msg "Re-apply everything")" printf ' [2] %s\n' "$(mca_msg "Re-apply everything")"
printf ' [3] %s\n' "$(mca_msg "Applications")" printf ' [3] %s\n' "$(mca_msg "Applications")"
@@ -579,13 +597,11 @@ mca_ui_menu() {
case "$choice" in case "$choice" in
1) 1)
MCA_UI_NEEDS_ACK=''
if [[ $CFG_ENABLED == yes ]]; then if [[ $CFG_ENABLED == yes ]]; then
mca_ui_cooked mca_do_disable mca_ui_run mca_do_disable
else else
mca_ui_cooked mca_do_enable mca_ui_run mca_do_enable
fi fi
[[ -n $MCA_UI_NEEDS_ACK ]] && mca_pause
;; ;;
# Not a plain apply: with the watcher running there is never # Not a plain apply: with the watcher running there is never
# anything left for one to do, and a menu entry that answers # anything left for one to do, and a menu entry that answers
@@ -594,17 +610,16 @@ mca_ui_menu() {
# what fixes an application that drifted, a flag file somebody # what fixes an application that drifted, a flag file somebody
# edited, or Steam after it restored its own script. # edited, or Steam after it restored its own script.
2) 2)
mca_ui_cooked mca_do_apply --rebuild mca_ui_run mca_do_apply --rebuild
mca_pause
;; ;;
3) 3)
if mca_ui_apps; then if mca_ui_apps; then
[[ $CFG_ENABLED == yes ]] && mca_ui_cooked mca_do_apply --rebuild [[ $CFG_ENABLED == yes ]] && mca_ui_run mca_do_apply --rebuild
fi fi
;; ;;
4) 4)
if mca_ui_settings; then if mca_ui_settings; then
[[ $CFG_ENABLED == yes ]] && mca_ui_cooked mca_do_apply --rebuild [[ $CFG_ENABLED == yes ]] && mca_ui_run mca_do_apply --rebuild
fi fi
;; ;;
q|Q) mca_ui_term_restore; trap - EXIT INT TERM; return 0 ;; q|Q) mca_ui_term_restore; trap - EXIT INT TERM; return 0 ;;
+6 -3
View File
@@ -56,7 +56,8 @@ mca_do_enable() {
mca_ok "$(mca_msg "Autoscroll is on for %d applications." "$MCA_N_ON")" mca_ok "$(mca_msg "Autoscroll is on for %d applications." "$MCA_N_ON")"
mca_note "$(mca_msg "Applications that are already running pick this up when they are restarted.")" [[ -n $MCA_IN_MENU ]] \
|| mca_note "$(mca_msg "Applications that are already running pick this up when they are restarted.")"
} }
mca_do_disable() { mca_do_disable() {
@@ -107,10 +108,12 @@ mca_do_apply() {
if (( rebuild )); then if (( rebuild )); then
mca_ok "$(mca_msg "Applied again to %d applications." "$MCA_N_ON")" mca_ok "$(mca_msg "Applied again to %d applications." "$MCA_N_ON")"
mca_say " $(mca_msg "Applications that are already running pick this up when they are restarted.")" [[ -n $MCA_IN_MENU ]] \
|| mca_say " $(mca_msg "Applications that are already running pick this up when they are restarted.")"
elif (( MCA_CHANGES )); then elif (( MCA_CHANGES )); then
mca_ok "$(mca_msg "Applied to %d applications." "$MCA_N_ON")" mca_ok "$(mca_msg "Applied to %d applications." "$MCA_N_ON")"
mca_say " $(mca_msg "Applications that are already running pick this up when they are restarted.")" [[ -n $MCA_IN_MENU ]] \
|| mca_say " $(mca_msg "Applications that are already running pick this up when they are restarted.")"
else else
mca_ok "$(mca_msg "Already applied to %d applications." "$MCA_N_ON")" mca_ok "$(mca_msg "Already applied to %d applications." "$MCA_N_ON")"
fi fi