diff --git a/README.md b/README.md index ec1850c..aa7dbe3 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,12 @@ as soon as it is set to run at login: that one bypasses the menu entry entirely, and without the switch a Steam started at login finds the patched script, restores it, gets patched again, and never gets past its update dialog. +The shortcuts Steam writes for single games get the switch as well. A game is +not an application this program has anything to offer — none of them is a +Chromium process and none appears in the applications list — but starting one +with Steam closed is a Steam start like any other, and leaving the switch out +there costs the interface its autoscroll for the rest of the session. + **The trade-off is real**: with verification off, Steam no longer repairs a damaged installation by itself. That is why Steam is a switch of its own rather than part of the general handling — turn it off in the settings and Steam is diff --git a/doc/middleclick-autoscroll.1.scd b/doc/middleclick-autoscroll.1.scd index 961e371..5c3f93d 100644 --- a/doc/middleclick-autoscroll.1.scd +++ b/doc/middleclick-autoscroll.1.scd @@ -107,6 +107,12 @@ an update dialog. The trade-off is that Steam no longer repairs a damaged installation on its own; that is why Steam is a switch of its own in the settings. +The shortcuts Steam writes for single games carry the switch too. A game is not +an application this program has anything to offer and none of them is listed +under *Applications*, but starting one with Steam closed is a Steam start like +any other, and without the switch it costs the interface its autoscroll for the +rest of the session. + Starting Steam some other way - from a terminal, from a script - leaves the switch out, and Steam puts its own copy of the script back for that session. The patch returns at the next apply with Steam closed. It is deliberately not diff --git a/src/lib/apply.sh b/src/lib/apply.sh index 25d0f3c..f2d06d1 100644 --- a/src/lib/apply.sh +++ b/src/lib/apply.sh @@ -107,6 +107,17 @@ mca_apply() { mca_steam_apply fi + # The shortcuts Steam writes for single games. They are not applications + # and are not offered as ones, but starting a game with Steam closed is a + # Steam start like any other: without the switch the client finds the + # patched helper script, puts its own back, and the interface loses + # autoscroll for the rest of the session. + if [[ $CFG_STEAM == yes ]]; then + for i in "${!MCA_STEAM_LINKS[@]}"; do + mca_steam_desktop_apply "${MCA_STEAM_LINKS[i]}" "${MCA_STEAM_LINK_FILES[i]}" + done + fi + # Steam's autostart entry carries Steam's own switch and follows the Steam # setting, not this one - leaving it out while Steam is patched is what puts # the client in an update loop - so both are checked inside. diff --git a/src/lib/detect.sh b/src/lib/detect.sh index a27ec17..db8ab52 100644 --- a/src/lib/detect.sh +++ b/src/lib/detect.sh @@ -180,6 +180,21 @@ mca_exec_flatpak_id() { return 1 } +# mca_exec_is_steam_link +# Whether an entry starts something inside Steam rather than starting Steam +# itself: it carries a steam:// address of its own. Steam writes one of those +# for every game somebody asks for a shortcut to, and the client's own entry +# never has one - it takes an address from the outside, through %U. +mca_exec_is_steam_link() { + local line="$1" prog="$2" + + [[ $line == *steam://* ]] || return 1 + case "${prog##*/}" in + steam|steam-runtime) return 0 ;; + esac + [[ $prog == flatpak:com.valvesoftware.Steam ]] +} + # --------------------------------------------------------------------------- # Is this Chromium? # --------------------------------------------------------------------------- @@ -401,6 +416,14 @@ MCA_NAMES=() # display name MCA_PROGS=() # resolved program, or a flatpak app id MCA_KINDS=() # app | browser | flatpak | steam | unknown | no +# The shortcuts Steam writes for single games. Not applications of their own - a +# game is whatever engine it was built with, and none of those reads a Chromium +# argument - so they are kept apart from the list rather than listed as +# something that got switched on. They do start Steam, which is why they are +# kept at all: the Steam module gives them Steam's own switch. +MCA_STEAM_LINKS=() # desktop file id +MCA_STEAM_LINK_FILES=() # the entry that is in effect for it + # A scan reads every desktop entry on the system, so the menu does it once and # then redraws from what it found. Applying rescans on its own, so nothing else # has to remember to invalidate this. @@ -417,6 +440,7 @@ mca_scan() { local -a c_ids=() c_files=() c_names=() c_progs=() c_browser=() c_stat=() MCA_IDS=(); MCA_FILES=(); MCA_NAMES=(); MCA_PROGS=(); MCA_KINDS=() + MCA_STEAM_LINKS=(); MCA_STEAM_LINK_FILES=() # Pass one: read the entries and work out what each of them starts. No # detection yet - that needs a stat per program, and those are collected so @@ -454,6 +478,12 @@ mca_scan() { prog="flatpak:$MCA_PROG" fi + if mca_exec_is_steam_link "$exec_line" "$prog"; then + MCA_STEAM_LINKS+=("$id") + MCA_STEAM_LINK_FILES+=("$file") + continue + fi + c_ids+=("$id"); c_files+=("$file"); c_names+=("$name") c_progs+=("$prog") if mca_desktop_is_browser; then c_browser+=(1); else c_browser+=(0); fi