Make the second menu entry an action instead of a report

"Apply now" had nothing to do in the normal case. Enabling applies, the
watcher handles everything installed afterwards, and the settings and
applications screens apply on their way out - so pressing it answered
"already applied to 14 applications" and that was the whole interaction.

It is now "Re-apply everything": the state is taken back and written again
from scratch. That is the answer to the question the status block can raise
but nothing could act on - Steam showing as not patched after a client
update, an application that drifted, a flag file edited by hand.

Uninstalling an application used to leave the entry shadowing it behind, in
the user home where the package manager cannot see it, offering to start a
program that is gone. A plain apply only looks at what exists now, so the
watcher never noticed either. Those are removed on every apply now, not just
when rebuilding.
This commit is contained in:
Felitendo committed 2026-08-16 20:44:19 +02:00
1 parent 9896260636
commit 1928143c46
9 files changed
+90 -20

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
# Overridable so a packager can pass the version it is actually building # Overridable so a packager can pass the version it is actually building
# (`make VERSION=$pkgver`). The literal below is the fallback for builds # (`make VERSION=$pkgver`). The literal below is the fallback for builds
# straight from a checkout, and is what a release tag has to carry. # straight from a checkout, and is what a release tag has to carry.
VERSION ?= 1.0.2 VERSION ?= 1.0.3
PREFIX ?= /usr PREFIX ?= /usr
DESTDIR ?= DESTDIR ?=
+2 -1
View File
@@ -59,7 +59,7 @@ all of them, in a way that survives the next package upgrade, is not:
Applications pick this up the next time they are started. Applications pick this up the next time they are started.
[1] Turn autoscroll on or off [1] Turn autoscroll on or off
[2] Apply now [2] Re-apply everything
[3] Applications [3] Applications
[4] Settings [4] Settings
[q] Quit [q] Quit
@@ -170,6 +170,7 @@ Run this before uninstalling the package.
| `… enable` | turn it on, apply, start watching | | `… enable` | turn it on, apply, start watching |
| `… disable` | turn it off and put everything back | | `… disable` | turn it off and put everything back |
| `… apply` | apply to anything new (this is what the watcher calls) | | `… apply` | apply to anything new (this is what the watcher calls) |
| `… apply --rebuild` | take everything back and apply it again, to repair a mess |
| `… status` | what is covered | | `… status` | what is covered |
| `… list` | every application that was found and how it is handled | | `… list` | every application that was found and how it is handled |
+8 -1
View File
@@ -36,10 +36,17 @@ is refused.
*disable* *disable*
Turn it off and put every file that was changed back the way it was. Turn it off and put every file that was changed back the way it was.
*apply* *apply* [*--rebuild*]
Apply to anything that has appeared since the last run. This is what the Apply to anything that has appeared since the last run. This is what the
watcher calls; running it by hand is only needed when the watcher is off. watcher calls; running it by hand is only needed when the watcher is off.
Entries left behind by an application that has since been uninstalled are
removed here too - the entry shadowing it lives in the user's home, where
the package manager that removed the application cannot see it.
With *--rebuild* everything is taken back first and written again from
scratch. That is the repair: it does not care what looks correct already.
*status* *status*
How many applications are covered, whether Steam is patched, and when the How many applications are covered, whether Steam is patched, and when the
last run was. last run was.
+9 -3
View File
@@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: middleclick-autoscroll 1.0.2\n" "Project-Id-Version: middleclick-autoscroll 1.0.3\n"
"Report-Msgid-Bugs-To: https://github.com/Felitendo/middleclick-autoscroll/issues\n" "Report-Msgid-Bugs-To: https://github.com/Felitendo/middleclick-autoscroll/issues\n"
"POT-Creation-Date: 2026-08-16 00:00+0200\n" "POT-Creation-Date: 2026-08-16 00:00+0200\n"
"PO-Revision-Date: 2026-08-16 00:00+0200\n" "PO-Revision-Date: 2026-08-16 00:00+0200\n"
@@ -77,8 +77,8 @@ msgstr "Anwendungen übernehmen das beim nächsten Start."
msgid "Turn autoscroll on or off" msgid "Turn autoscroll on or off"
msgstr "Autoscroll ein- oder ausschalten" msgstr "Autoscroll ein- oder ausschalten"
msgid "Apply now" msgid "Re-apply everything"
msgstr "Jetzt anwenden" msgstr "Alles neu anwenden"
msgid "Applications" msgid "Applications"
msgstr "Anwendungen" msgstr "Anwendungen"
@@ -164,6 +164,9 @@ msgstr "Autoscroll ist aus, alle Änderungen wurden zurückgenommen."
msgid "Autoscroll is off. Turn it on first." msgid "Autoscroll is off. Turn it on first."
msgstr "Autoscroll ist aus. Erst einschalten." msgstr "Autoscroll ist aus. Erst einschalten."
msgid "Applied again to %d applications."
msgstr "Erneut auf %d Anwendungen angewendet."
msgid "Applied to %d applications." msgid "Applied to %d applications."
msgstr "Auf %d Anwendungen angewendet." msgstr "Auf %d Anwendungen angewendet."
@@ -190,6 +193,9 @@ msgstr "Ausschalten und alles zurücknehmen"
msgid "Apply to anything installed since the last run" msgid "Apply to anything installed since the last run"
msgstr "Auf alles anwenden, was seit dem letzten Lauf dazugekommen ist" msgstr "Auf alles anwenden, was seit dem letzten Lauf dazugekommen ist"
msgid "Take everything back and apply it again"
msgstr "Alles zurücknehmen und neu anwenden"
msgid "Show what is covered" msgid "Show what is covered"
msgstr "Anzeigen, was abgedeckt ist" msgstr "Anzeigen, was abgedeckt ist"
+8 -2
View File
@@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: middleclick-autoscroll 1.0.2\n" "Project-Id-Version: middleclick-autoscroll 1.0.3\n"
"Report-Msgid-Bugs-To: https://github.com/Felitendo/middleclick-autoscroll/issues\n" "Report-Msgid-Bugs-To: https://github.com/Felitendo/middleclick-autoscroll/issues\n"
"POT-Creation-Date: 2026-08-16 00:00+0200\n" "POT-Creation-Date: 2026-08-16 00:00+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -77,7 +77,7 @@ msgstr ""
msgid "Turn autoscroll on or off" msgid "Turn autoscroll on or off"
msgstr "" msgstr ""
msgid "Apply now" msgid "Re-apply everything"
msgstr "" msgstr ""
msgid "Applications" msgid "Applications"
@@ -164,6 +164,9 @@ msgstr ""
msgid "Autoscroll is off. Turn it on first." msgid "Autoscroll is off. Turn it on first."
msgstr "" msgstr ""
msgid "Applied again to %d applications."
msgstr ""
msgid "Applied to %d applications." msgid "Applied to %d applications."
msgstr "" msgstr ""
@@ -190,6 +193,9 @@ msgstr ""
msgid "Apply to anything installed since the last run" msgid "Apply to anything installed since the last run"
msgstr "" msgstr ""
msgid "Take everything back and apply it again"
msgstr ""
msgid "Show what is covered" msgid "Show what is covered"
msgstr "" msgstr ""
+2
View File
@@ -110,6 +110,8 @@ mca_apply() {
[[ $CFG_AUTOSTART == yes ]] && mca_autostart_apply [[ $CFG_AUTOSTART == yes ]] && mca_autostart_apply
[[ $CFG_SPOTIFY == yes ]] && mca_spotify_apply [[ $CFG_SPOTIFY == yes ]] && mca_spotify_apply
mca_prune_orphans
if (( MCA_CHANGES )) && mca_have update-desktop-database; then if (( MCA_CHANGES )) && mca_have update-desktop-database; then
update-desktop-database "$MCA_APPDIR" 2>/dev/null || true update-desktop-database "$MCA_APPDIR" 2>/dev/null || true
fi fi
+10 -4
View File
@@ -495,7 +495,7 @@ mca_ui_menu() {
mca_ui_status mca_ui_status
printf '\n' printf '\n'
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 "Apply now")" printf ' [2] %s\n' "$(mca_msg "Re-apply everything")"
printf ' [3] %s\n' "$(mca_msg "Applications")" printf ' [3] %s\n' "$(mca_msg "Applications")"
printf ' [4] %s\n' "$(mca_msg "Settings")" printf ' [4] %s\n' "$(mca_msg "Settings")"
printf ' [q] %s\n' "$(mca_msg "Quit")" printf ' [q] %s\n' "$(mca_msg "Quit")"
@@ -519,18 +519,24 @@ mca_ui_menu() {
fi fi
[[ -n $MCA_UI_NEEDS_ACK ]] && mca_pause [[ -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
# "already done" every time is not an action. This is the repair -
# everything is taken back and written again from scratch, which is
# what fixes an application that drifted, a flag file somebody
# edited, or Steam after it restored its own script.
2) 2)
mca_ui_cooked mca_do_apply mca_ui_cooked mca_do_apply --rebuild
mca_pause mca_pause
;; ;;
3) 3)
if mca_ui_apps; then if mca_ui_apps; then
[[ $CFG_ENABLED == yes ]] && mca_ui_cooked mca_do_apply --changed [[ $CFG_ENABLED == yes ]] && mca_ui_cooked 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 --changed [[ $CFG_ENABLED == yes ]] && mca_ui_cooked 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 ;;
+34
View File
@@ -418,6 +418,40 @@ mca_spotify_apply() {
return 0 return 0
} }
# ---------------------------------------------------------------------------
# Leftovers
# ---------------------------------------------------------------------------
# mca_prune_orphans
# Removes generated entries whose application is gone.
#
# Uninstalling something deletes its entry from /usr/share/applications, but the
# copy shadowing it is in the user's home and pacman knows nothing about it. It
# would sit in the menu forever, offering to start a program that is no longer
# installed - and the watcher would not notice, because a plain apply only ever
# looks at what is there now.
mca_prune_orphans() {
local kind path source line
local -a lines=()
[[ -f $MCA_LEDGER ]] || return 0
mapfile -t lines < "$MCA_LEDGER"
for line in "${lines[@]}"; do
IFS=$'\t' read -r kind path source <<< "$line"
[[ $kind == shadow && -n $source ]] || continue
[[ -e $source ]] && continue
# Only ever remove something still recognisably ours.
if [[ -f $path ]] && grep -q "^$MCA_MARK_SHADOW=" "$path" 2>/dev/null; then
rm -f -- "$path"
MCA_CHANGES=$(( MCA_CHANGES + 1 ))
fi
mca_ledger_forget "$path"
done
return 0
}
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Undo # Undo
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
+16 -8
View File
@@ -76,11 +76,11 @@ mca_do_disable() {
} }
mca_do_apply() { mca_do_apply() {
local changed=0 arg local rebuild=0 arg
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
--changed) changed=1 ;; --rebuild) rebuild=1 ;;
--quiet) MCA_QUIET=1 ;; --quiet) MCA_QUIET=1 ;;
esac esac
done done
@@ -95,17 +95,24 @@ mca_do_apply() {
return 1 return 1
fi fi
# A settings change can take an application out of scope as well as bring # Start from a clean slate. Needed after a settings change, which can take
# one in, and only a full undo can tell the difference, so that path starts # an application out of scope as well as bring one in and where only a full
# from a clean slate. The watcher never does this: rewriting files that are # undo can tell the difference, and it is what makes the repair a repair:
# already correct would make it trigger itself. # whatever drifted is written again rather than left because it is "already
if (( changed )); then # applied".
#
# The watcher never does this. Rewriting files that are already correct
# would change their timestamps, and it is watching those directories.
if (( rebuild )); then
mca_revert mca_revert
fi fi
mca_apply mca_apply
if (( MCA_CHANGES )); then 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.")"
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.")" mca_say " $(mca_msg "Applications that are already running pick this up when they are restarted.")"
else else
@@ -160,6 +167,7 @@ mca_do_help() {
enable $(mca_msg "Turn autoscroll on") enable $(mca_msg "Turn autoscroll on")
disable $(mca_msg "Turn it off and put everything back") disable $(mca_msg "Turn it off and put everything back")
apply $(mca_msg "Apply to anything installed since the last run") apply $(mca_msg "Apply to anything installed since the last run")
apply --rebuild $(mca_msg "Take everything back and apply it again")
status $(mca_msg "Show what is covered") status $(mca_msg "Show what is covered")
list $(mca_msg "List every application that was found") list $(mca_msg "List every application that was found")
-h, --help $(mca_msg "Show this help") -h, --help $(mca_msg "Show this help")