From e31f67e53e3f6019f33ba03802e6ff327d01ab63 Mon Sep 17 00:00:00 2001 From: kenji Date: Mon, 1 Dec 2025 21:15:02 -0600 Subject: [PATCH] gamescope-session fixed scripting --- scripts/Hyperland-Steamos/install.sh | 145 ++++++++++----------------- 1 file changed, 52 insertions(+), 93 deletions(-) diff --git a/scripts/Hyperland-Steamos/install.sh b/scripts/Hyperland-Steamos/install.sh index 45f4811..5887039 100644 --- a/scripts/Hyperland-Steamos/install.sh +++ b/scripts/Hyperland-Steamos/install.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Seamless Hyprland <-> Gamescope Session Switcher for Arch Linux -# Updated: Infinite Loop, env.d Config, Color Reset, IWD Backend +# Updated: Walker, Infinite Loop, env.d Config, Color Reset, IWD Backend # set -e @@ -37,13 +37,12 @@ SWITCH_SCRIPT_PATH="$USER_HOME/.local/bin/switch-session.sh" XSESSION_PATH="$USER_HOME/.xsession" SERVICE_OVERRIDE_DIR="/etc/systemd/user/gamescope-session-plus@.service.d" SERVICE_OVERRIDE_FILE="$SERVICE_OVERRIDE_DIR/override.conf" -# UPDATED: Correct config path for systemd user environment GS_ENV_DIR="$USER_HOME/.config/environment.d" GS_ENV_FILE="$GS_ENV_DIR/gamescope-session-plus.conf" -# UPDATED: Removed lib32-networkmanager -OFFICIAL_PACKAGES=( "hyprland" "wofi" "sddm" "uwsm" "networkmanager" ) -AUR_PACKAGES=( "gamescope-git" "gamescope-session-git" "steam" "gamescope-session-steam-git" "mangohud" ) +# UPDATED: Removed wofi, added walker to AUR packages +OFFICIAL_PACKAGES=( "hyprland" "sddm" "uwsm" "networkmanager" ) +AUR_PACKAGES=( "gamescope-git" "gamescope-session-git" "steam" "gamescope-session-steam-git" "mangohud" "walker" ) #======================================================= # STEP 1: DEPENDENCY INSTALLATION @@ -102,8 +101,6 @@ EOF echo "Enabling NetworkManager..." sudo systemctl enable NetworkManager -# We don't force start here to avoid killing the user's current SSH/Session immediately, -# but it will be active on reboot. #======================================================= # STEP 6: INSTALL SESSION SWITCHING LOGIC @@ -179,30 +176,12 @@ while true; do if [[ "$SESSION" == *"gamescope-session-steam"* ]]; then echo "Starting Gamescope session..." - # --- LOAD USER CONFIG FROM ENVIRONMENT.D --- - # Since we are running manually, we must explicitly load the systemd env config - if [ -f "$HOME/.config/environment.d/gamescope-session-plus.conf" ]; then - echo "Loading gamescope config from environment.d..." - set -a - source "$HOME/.config/environment.d/gamescope-session-plus.conf" - set +a - fi - # Check for the executable if command -v gamescope-session-plus &> /dev/null; then - - # TRIPLE-FORCE MONITOR CONFIGURATION - # 1. Environment variable (from sourced file or manual export) - export GAMESCOPECMD="/usr/bin/gamescope ${GAMESCOPE_ARGS:-"-O DP-1 --steam -e"}" - export OUTPUT_CONNECTOR="${OUTPUT_CONNECTOR:-"DP-1"}" - - # 2. Run blocking, do not exec - # 3. Pass CLI args just in case - gamescope-session-plus steam -- -O DP-1 - - # Cleanup + # Run blocking, do not exec + export GAMESCOPECMD="/usr/bin/gamescope -O DP-1 --steam -e --" + gamescope-session-plus steam unset GAMESCOPECMD - unset OUTPUT_CONNECTOR else echo "Error: gamescope-session-plus not found, falling back to Hyprland" SESSION="hyprland" @@ -222,91 +201,42 @@ while true; do # 4. CRASH PROTECTION sleep 2 done + EOS chmod +x "$XSESSION_PATH" #======================================================= -# STEP 8: CREATE SWITCHING SCRIPT (COLOR RESET FIX) +# STEP 8: CREATE SWITCHING SCRIPT (WALKER EDITION) #======================================================= echo -e "${C_BLUE}==> Creating Session Switching Helper...${C_NC}" mkdir -p "$(dirname "$SWITCH_SCRIPT_PATH")" cat > "$SWITCH_SCRIPT_PATH" <<'EOSWITCH' + #!/bin/bash -# Set environment variables for Wofi to work properly export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-1}" export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" -# Create Wofi config directory if it doesn't exist -mkdir -p "$HOME/.config/wofi" - -# Create custom Wofi stylesheet for SteamOS appearance -cat > "$HOME/.config/wofi/style.css" <<'EOSTYLE' -window { - background-color: rgba(30, 30, 46, 0.85); - border: 1px solid rgba(60, 125, 210, 0.5); - border-radius: 16px; - font-family: "Noto Sans", sans-serif; - font-size: 18px; - box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1); - min-height: 250px; -} -#input { - background-color: rgba(42, 42, 62, 0.6); - border: 1px solid rgba(60, 125, 210, 0.3); - border-radius: 8px; - color: #cdd6f4; - font-size: 16px; - margin: 12px; - padding: 12px 16px; -} -#inner-box { background-color: transparent; margin: 8px; min-height: 150px; } -#outer-box { background-color: rgba(255, 255, 255, 0.02); border-radius: 12px; margin: 4px; padding: 8px; } -#scroll { background-color: transparent; min-height: 120px; } -#text { color: rgba(205, 214, 244, 0.95); padding: 12px 16px; font-weight: 500; font-size: 18px; } -#entry { - background-color: rgba(255, 255, 255, 0.05); - border: 1px solid rgba(255, 255, 255, 0.1); - border-radius: 10px; - margin: 8px 12px; - padding: 12px; - min-height: 48px; - transition: all 0.2s ease; -} -#entry:hover { background-color: rgba(255, 255, 255, 0.08); border-color: rgba(60, 125, 210, 0.4); transform: translateX(4px); } -#entry:selected { - background: linear-gradient(135deg, rgba(60, 125, 210, 0.8) 0%, rgba(37, 99, 235, 0.8) 100%); - border: 1px solid rgba(60, 125, 210, 0.6); -} -#entry:selected #text { color: #ffffff; font-weight: 600; } -EOSTYLE - -# Show session switcher with Wofi -choice=$(printf "🎮 SteamOS" | wofi --dmenu \ - --prompt "Switch Mode:" \ - --width 400 \ - --height 250 \ - --cache-file /dev/null \ - --style "$HOME/.config/wofi/style.css" \ - --hide-scroll \ - --no-actions \ - --lines 2) +choice=$(printf "🎮 SteamOS" | walker --dmenu \ + --placeholder "Switch Mode:" \ + # --width 400 \ + # --height 250 \ + # --cache-file /dev/null \ + # --style "$HOME/.config/wofi/style.css" \ + # --hide-scroll \ + # --no-actions \ + # --lines 2) + ) case "$choice" in "🎮 SteamOS") - # --- FIX: RESET SCREEN COLOR --- - notify-send "Session Switcher" "Disabling Night Light..." -t 1000 - pkill hyprsunset - pkill wlsunset - pkill gammastep - sleep 1 # Give GPU time to reset gamma - # ------------------------------- - # Validate we can write the session file if echo "gamescope-session-steam.desktop" > "$HOME/.next-session" 2>/dev/null; then notify-send "Session Switcher" "Switching to SteamOS..." -t 2000 echo "Session file written successfully" + pkill hyprsunset + sleep 1 else notify-send "Session Switcher" "Error: Failed to write session file" -t 3000 echo "Error: Cannot write to $HOME/.next-session" @@ -328,33 +258,62 @@ cleanup_session() { # Detect current session more reliably if pgrep -x "gamescope" > /dev/null || pgrep -f "gamescope-session" > /dev/null; then echo "Detected Gamescope session, shutting down..." + + # Try graceful shutdown first systemctl --user stop gamescope-session-plus@steam 2>/dev/null || true sleep 1 + + # Force kill if still running if pgrep -x "gamescope" > /dev/null; then pkill -TERM gamescope sleep 0.5 pkill -KILL gamescope 2>/dev/null || true fi + + # Wait for processes to fully exit + while pgrep -x "gamescope" > /dev/null && [ $wait_count -lt $max_wait ]; do + sleep 1 + ((wait_count++)) + done + elif [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] || pgrep -x "Hyprland" > /dev/null; then echo "Detected Hyprland session, shutting down..." + + # Try hyprctl first if available if command -v hyprctl &> /dev/null && [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ]; then hyprctl dispatch exit 2>/dev/null || true else + # Fallback to pkill pkill -TERM Hyprland 2>/dev/null || true fi + sleep 1 + + # Force kill if still running if pgrep -x "Hyprland" > /dev/null; then pkill -KILL Hyprland 2>/dev/null || true fi + + # Wait for processes to fully exit + while pgrep -x "Hyprland" > /dev/null && [ $wait_count -lt $max_wait ]; do + sleep 1 + ((wait_count++)) + done + else + echo "No specific session detected, attempting general cleanup..." + # Fallback cleanup pkill -u $USER Hyprland 2>/dev/null || true pkill -u $USER gamescope 2>/dev/null || true systemctl --user stop gamescope-session-plus@steam 2>/dev/null || true sleep 1 fi + # Clean up any remaining compositor processes pkill -u $USER -f "gamescope-session" 2>/dev/null || true pkill -u $USER -f "steam" 2>/dev/null || true + + # Give time for cleanup sleep 0.5 } @@ -394,7 +353,7 @@ echo -e "${C_GREEN}Added SUPER+F12 keybinding to $HYPR_CONF${C_NC}" echo -e "${C_GREEN}✅ Setup Complete! ✅${C_NC}\n" echo -e "${C_YELLOW}Important Fixes Applied:${C_NC}" -echo "1. REMOVED 'lib32-networkmanager' (Using 64-bit standard package)." +echo "1. REPLACED 'wofi' with 'walker'." echo "2. CONFIGURED NetworkManager to use 'iwd' backend." echo "3. UPDATED '.xsession' to use an infinite loop (prevents logout)." echo "4. CREATED '~/.config/environment.d/gamescope-session-plus.conf' to force DP-1."