mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-14 15:44:47 +02:00
Steamify launcher: StartupWMClass so GNOME's dock matches the app window; session tool records the last desktop from its shell
This commit is contained in:
1 parent
68342e7a24
commit
0e0bf57ca8
4 files changed
+20
-16
No files matched your search
+6
-1
@@ -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)."
|
||||
|
||||
@@ -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"
|
||||
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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)"
|
||||
|
||||
Reference in new issue
Block a user