# shellcheck shell=bash # # Steam. # # Steam's interface is CEF, so the feature is there - but Steam builds the # command line for its web helper itself and offers no way to add to it. The # only place to get an argument in is the shell script that starts the helper, # which lives inside Steam's own installation: # # ~/.local/share/Steam/ubuntu12_64/steamwebhelper_sniper_wrap.sh # # Steam compares the installed files against its manifest at every start - by # size, not by content - and restores whatever differs, which is why the # launcher gets -noverifyfiles as well. The trade-off is real and belongs to # the user, so this is a switch of its own rather than part of the general # application handling: with verification off, Steam no longer repairs a # damaged installation by itself. # # Every way of starting Steam has to carry that switch, or the two programs # spend the session undoing each other: Steam restores the script, the watcher # patches it again, Steam restores it again, and the client never gets past its # update dialog. So the autostart entry gets it as well as the menu one (see # mca_autostart_apply), and the patch below stays out of the way of a client # that is already running. # # The file comes back on every client update, and the watcher re-applies the # patch when that happens. MCA_STEAM_LAUNCH_FLAG='-noverifyfiles' # Every place a Steam installation is known to live, resolved and de-duplicated # because ~/.steam/steam is normally a symlink into ~/.local/share. # # Which of these is the real one depends on how Steam was installed: Valve's # own package and the Arch one use ~/.local/share/Steam, Debian's puts it in # ~/.steam/debian-installation, and the Flatpak and the snap each keep it # inside the private tree their sandbox gives them. mca_steam_roots() { local candidates=( "$MCA_XDG_DATA/Steam" "$HOME/.steam/steam" "$HOME/.steam/root" "$HOME/.steam/debian-installation" "$HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam" "$HOME/.var/app/com.valvesoftware.Steam/data/Steam" "$HOME/snap/steam/common/.local/share/Steam" ) local dir real local -A seen=() for dir in "${candidates[@]}"; do [[ -d $dir ]] || continue real="$(readlink -f -- "$dir" 2>/dev/null)" || continue [[ -n ${seen[$real]+set} ]] && continue seen[$real]=1 printf '%s\n' "$real" done } # The script to patch inside a Steam installation. Newer clients start the # helper through a wrapper inside the container runtime; older ones exec it # from steamwebhelper.sh directly, and that one forwards its arguments too. mca_steam_script() { local root="$1" f for f in \ "$root/ubuntu12_64/steamwebhelper_sniper_wrap.sh" \ "$root/ubuntu12_64/steamwebhelper.sh" do [[ -f $f && -w $f ]] && { printf '%s\n' "$f"; return 0; } done return 1 } mca_steam_installed() { local root while IFS= read -r root; do mca_steam_script "$root" > /dev/null && return 0 done < <(mca_steam_roots) return 1 } # mca_steam_running # Steam records its own process id beside its installation while it runs. The # file outlives a crash, so the id is checked rather than believed. mca_steam_running() { local f pid for f in \ "$HOME/.steam/steam.pid" \ "$HOME/.var/app/com.valvesoftware.Steam/.steam/steam.pid" \ "$HOME/snap/steam/common/.steam/steam.pid" do [[ -r $f ]] || continue pid="$(< "$f")" [[ $pid =~ ^[0-9]+$ ]] || continue kill -0 "$pid" 2>/dev/null && return 0 done return 1 } # mca_steam_script_patched