From 0e0bf57ca8c8eb6cc802f3828dbb7f1b7911e2b5 Mon Sep 17 00:00:00 2001 From: Rick Peters Date: Wed, 14 Oct 2026 15:17:17 +0200 Subject: [PATCH] Steamify launcher: StartupWMClass so GNOME's dock matches the app window; session tool records the last desktop from its shell --- lib/boot-session.sh | 7 ++++++- lib/login-manager.sh | 21 ++++++++++++--------- lib/wizard-shortcut.sh | 1 + patches/steamify-gdm-steam-set-session.sh | 15 +++++---------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/boot-session.sh b/lib/boot-session.sh index 1a2831e..601eb11 100644 --- a/lib/boot-session.sh +++ b/lib/boot-session.sh @@ -17,13 +17,18 @@ boot_status() { [[ -f "$BOOT_UNIT" ]] && systemctl is-enabled -q "$BOOT_UNIT_NAME" 2>/dev/null } +boot_desktop_arg() { + # Our session tool (installed with GNOME) resolves "desktop" to the preferred desktop; CachyOS's own takes a session name. + if [[ -f "$GDM_FIX_DIR/steam-set-session" ]]; then echo desktop; else echo plasma.desktop; fi +} + boot_enable() { info "Setting the PC to boot into the desktop..." # The sync bridge (plasma-login-manager only; not there with SDDM) copies # the session into the base config; run it right away rather than rely # on its path unit, which could still be pending when the login manager # starts. - service_file "$BOOT_UNIT_NAME" SESSION_SYNC="$SESSION_SYNC" DESKTOP_SESSION="$(desktop_session_file)" | sudo tee "$BOOT_UNIT" > /dev/null + service_file "$BOOT_UNIT_NAME" SESSION_SYNC="$SESSION_SYNC" DESKTOP_SESSION="$(boot_desktop_arg)" | sudo tee "$BOOT_UNIT" > /dev/null sudo systemctl daemon-reload sudo systemctl enable "$BOOT_UNIT_NAME" || { err "Enabling $BOOT_UNIT_NAME failed."; return 1; } ok "Boots into the desktop from the next boot on (Return to Gaming Mode still works)." diff --git a/lib/login-manager.sh b/lib/login-manager.sh index 437e8cd..c33553c 100644 --- a/lib/login-manager.sh +++ b/lib/login-manager.sh @@ -122,9 +122,10 @@ gaming_enable() { remove_session_sync switch_to_gdm || return 1 configure_gdm_autologin || return 1 - gdm_fix_install || return 1 ;; esac + # CachyOS's own session tools only go to Plasma and only know SDDM and plasma-login-manager: with GNOME installed ours replace them. + if [[ "$LOGIN_MANAGER" == gdm ]] || desktop_installed gnome; then session_tools_install || return 1; fi # (NVIDIA with single user mode from before the conversion: its desktop autologin would pin the Plasma session.) single_login_release create_desktop_shortcut @@ -138,8 +139,8 @@ gaming_disable() { info "Turning off booting into gaming mode..." remove_sddm_autologin remove_session_sync + session_tools_remove if [[ "$(current_display_manager)" == gdm ]]; then - gdm_fix_remove restore_gdm_config else restore_plasmalogin_config @@ -358,7 +359,7 @@ restore_gdm_config() { fi } -gdm_fix_install() { +session_tools_install() { # CachyOS's steam-set-session and steamos-session-select only know # plasma-login-manager/SDDM and KDE. Ours replace them at the same paths # (Steam's Switch to Desktop calls them by path); a pacman hook puts them @@ -366,13 +367,15 @@ gdm_fix_install() { info "Making the session switching GDM-aware..." sudo mkdir -p "$GDM_FIX_DIR" patch_file steamify-gdm-steam-set-session.sh | sudo install -Dm755 /dev/stdin "$GDM_FIX_DIR/steam-set-session" && - patch_file steamify-gdm-session-select.sh | fill DESKTOP_SESSION="$(desktop_session_file)" | + patch_file steamify-gdm-session-select.sh | sudo install -Dm755 /dev/stdin "$GDM_FIX_DIR/steamos-session-select" || { err "Installing the GDM session tools failed."; return 1; } patch_file steamify-gdm.hook | fill DIR="$GDM_FIX_DIR" | sudo install -Dm644 /dev/stdin "$GDM_HOOK" - # steamos-session-select logs in again through this helper (no password: it runs from the gaming session and from a shortcut). - patch_file steamify-gdm-relogin.sh | sudo install -Dm755 /dev/stdin "$GDM_RELOGIN" - echo "$TARGET_USER ALL=(root) NOPASSWD: $GDM_RELOGIN" | sudo install -Dm440 /dev/stdin "$GDM_SUDOERS" - sudo visudo -cf "$GDM_SUDOERS" > /dev/null || { sudo rm -f "$GDM_SUDOERS"; err "The sudoers rule for GDM is invalid."; return 1; } + if [[ "$(current_display_manager)" == gdm || "$LOGIN_MANAGER" == gdm ]]; then + # steamos-session-select logs in again through this helper (no password: it runs from the gaming session and from a shortcut). + patch_file steamify-gdm-relogin.sh | sudo install -Dm755 /dev/stdin "$GDM_RELOGIN" + echo "$TARGET_USER ALL=(root) NOPASSWD: $GDM_RELOGIN" | sudo install -Dm440 /dev/stdin "$GDM_SUDOERS" + sudo visudo -cf "$GDM_SUDOERS" > /dev/null || { sudo rm -f "$GDM_SUDOERS"; err "The sudoers rule for GDM is invalid."; return 1; } + fi for f in /usr/lib/steamos/steam-set-session /usr/bin/steamos-session-select; do [[ -f "$f" && ! -f "$f.bak-steamify" ]] && sudo cp -a "$f" "$f.bak-steamify" done @@ -383,7 +386,7 @@ gdm_fix_install() { ok "GDM autologin into gamescope is set up." } -gdm_fix_remove() { +session_tools_remove() { sudo rm -f "$GDM_HOOK" "$GDM_SUDOERS" "$GDM_RELOGIN" for f in /usr/lib/steamos/steam-set-session /usr/bin/steamos-session-select; do [[ -f "$f.bak-steamify" ]] && sudo mv "$f.bak-steamify" "$f" diff --git a/lib/wizard-shortcut.sh b/lib/wizard-shortcut.sh index 63ff998..c41b8be 100644 --- a/lib/wizard-shortcut.sh +++ b/lib/wizard-shortcut.sh @@ -121,6 +121,7 @@ Exec=$WIZARD_APP_LAUNCHER Icon=$icon Terminal=false Categories=Game;System;Settings; +StartupWMClass=steamify-ui X-Steamify-Shortcut=true" printf '%s\n' "$entry" | install_executable "$WIZARD_APP_ENTRY" 644 printf '%s\n' "$entry" | install_executable "$(wizard_desktop_dir)/$WIZARD_DESKTOP_NAME" 755 diff --git a/patches/steamify-gdm-steam-set-session.sh b/patches/steamify-gdm-steam-set-session.sh index 46ad87b..ba34bdb 100644 --- a/patches/steamify-gdm-steam-set-session.sh +++ b/patches/steamify-gdm-steam-set-session.sh @@ -25,17 +25,12 @@ resolve_desktop() { echo gnome.desktop } remember_desktop() { - # Leaving a desktop for gamescope: which desktop it was (from the user's own session). - local uid="${PKEXEC_UID:-}" id desktop + # Leaving a desktop for gamescope: which desktop it was, from the shell the user is running. + local uid="${PKEXEC_UID:-}" kind [[ -n "$uid" ]] || return 0 - id="$(loginctl show-user "$uid" -p Display --value 2>/dev/null)" - [[ -n "$id" ]] || return 0 - desktop="$(loginctl show-session "$id" -p Desktop --value 2>/dev/null | tr 'A-Z' 'a-z')" - case "$desktop" in - *gnome*) kind=gnome ;; - *kde*|*plasma*) kind=kde ;; - *) return 0 ;; - esac + if pgrep -u "$uid" -x gnome-shell >/dev/null; then kind=gnome + elif pgrep -u "$uid" -x plasmashell >/dev/null; then kind=kde + else return 0; fi mkdir -p /var/lib/steamify && echo "$kind" > /var/lib/steamify/last-desktop } [[ "$SESSION" == desktop ]] && SESSION="$(resolve_desktop)"