diff --git a/po/de.po b/po/de.po index e41f360..188ab54 100644 --- a/po/de.po +++ b/po/de.po @@ -94,6 +94,9 @@ msgstr "Beenden" msgid "Press any key to continue..." msgstr "Beliebige Taste drücken …" +msgid "One moment..." +msgstr "Einen Moment …" + #. Settings msgid "Turn off middle-click paste" msgstr "Mittelklick-Einfügen abschalten" diff --git a/po/middleclick-autoscroll.pot b/po/middleclick-autoscroll.pot index 7fe79d2..e59003c 100644 --- a/po/middleclick-autoscroll.pot +++ b/po/middleclick-autoscroll.pot @@ -94,6 +94,9 @@ msgstr "" msgid "Press any key to continue..." msgstr "" +msgid "One moment..." +msgstr "" + #. Settings msgid "Turn off middle-click paste" msgstr "" diff --git a/src/lib/common.sh b/src/lib/common.sh index c2d8be8..487e688 100644 --- a/src/lib/common.sh +++ b/src/lib/common.sh @@ -215,12 +215,6 @@ else MCA_C_GREEN='' MCA_C_YELLOW='' MCA_C_RED='' 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 # systemd unit, which has no terminal and logs to the journal anyway. MCA_QUIET='' @@ -228,8 +222,8 @@ MCA_QUIET='' 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_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_note() { MCA_UI_NEEDS_ACK=1; [[ -n $MCA_QUIET ]] || printf '%s•%s %s\n' "$MCA_C_DIM" "$MCA_C_RESET" "$*"; } +mca_bad() { printf '%s✘%s %s\n' "$MCA_C_RED" "$MCA_C_RESET" "$*" >&2; } +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; } diff --git a/src/lib/menu.sh b/src/lib/menu.sh index 2face83..90bf89f 100644 --- a/src/lib/menu.sh +++ b/src/lib/menu.sh @@ -31,14 +31,25 @@ mca_ui_term_restore() { MCA_TERM_SAVED='' } -# Runs an action with the terminal handed back to normal line mode, so anything -# it prints or prompts for behaves the way a program expects. -mca_ui_cooked() { - mca_ui_term_restore - "$@" - local rc=$? - mca_ui_term_raw - return $rc +# What the last action printed. The menu shows it under the status until the +# next key, so nothing has to wait for a key on a screen of its own. +MCA_UI_MSG='' + +# Set while the menu runs. Its status block already says that running +# applications need a restart, so the actions leave that line out there. +MCA_IN_MENU='' + +# mca_ui_run +# 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 @@ -432,8 +443,7 @@ mca_ui_apps() { count=${#MCA_IDS[@]} if (( count == 0 )); then - printf '\n %s\n' "$(mca_msg "No Chromium-based applications found.")" - mca_pause + MCA_UI_MSG="$(mca_msg "No Chromium-based applications found.")" return 1 fi @@ -550,8 +560,9 @@ mca_ui_apps() { # --------------------------------------------------------------------------- mca_ui_menu() { - local choice + local choice line + MCA_IN_MENU=1 mca_ui_term_raw trap 'mca_ui_term_restore' EXIT INT TERM @@ -562,6 +573,13 @@ mca_ui_menu() { mca_head " $MCA_PRETTY" mca_ui_status 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 ' [2] %s\n' "$(mca_msg "Re-apply everything")" printf ' [3] %s\n' "$(mca_msg "Applications")" @@ -579,13 +597,11 @@ mca_ui_menu() { case "$choice" in 1) - MCA_UI_NEEDS_ACK='' if [[ $CFG_ENABLED == yes ]]; then - mca_ui_cooked mca_do_disable + mca_ui_run mca_do_disable else - mca_ui_cooked mca_do_enable + mca_ui_run mca_do_enable fi - [[ -n $MCA_UI_NEEDS_ACK ]] && mca_pause ;; # Not a plain apply: with the watcher running there is never # 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 # edited, or Steam after it restored its own script. 2) - mca_ui_cooked mca_do_apply --rebuild - mca_pause + mca_ui_run mca_do_apply --rebuild ;; 3) 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 ;; 4) 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 ;; q|Q) mca_ui_term_restore; trap - EXIT INT TERM; return 0 ;; diff --git a/src/middleclick-autoscroll b/src/middleclick-autoscroll index 9255fbc..2f89c83 100644 --- a/src/middleclick-autoscroll +++ b/src/middleclick-autoscroll @@ -56,7 +56,8 @@ mca_do_enable() { 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() { @@ -107,10 +108,12 @@ mca_do_apply() { if (( rebuild )); then 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 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 mca_ok "$(mca_msg "Already applied to %d applications." "$MCA_N_ON")" fi