diff --git a/scripts/Hyperland-Steamos/install.sh b/scripts/Hyperland-Steamos/install.sh index cd64cff..554fd8e 100755 --- 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: High Priority Scheduling (Fixes Stutter), Walker, Configurable Refresh Rate +# Updated: Restore Functionality, Safe Priority Boost, Directory Fix # set -e @@ -19,7 +19,7 @@ if [ "$EUID" -eq 0 ]; then fi USER_NAME=$(whoami) -USER_HOME=$(eval echo "~$USER_NAME") +USER_HOME=$HOME # --- Banner --- echo -e "${C_BLUE}===================================================================${C_NC}" @@ -40,7 +40,7 @@ if [ -n "$USER_REFRESH" ]; then fi # --- Script Variables --- -HYPR_CONF="$USER_HOME/.config/hypr/hyprland.conf" +HYPR_CONF="$USER_HOME/.config/hypr/bindings.conf" 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" @@ -85,20 +85,23 @@ systemctl --user daemon-reload # STEP 4: CONFIGURE GAMESCOPE ENVIRONMENT #======================================================= echo -e "${C_BLUE}==> Configuring Gamescope Monitor Settings (DP-1)...${C_NC}" -echo "Writing to: $GS_ENV_FILE" + +# Fix for "No such file or directory": Ensure parent dir exists +if [ -f "$GS_ENV_DIR" ]; then + echo "Warning: $GS_ENV_DIR exists as a file. Removing it..." + rm "$GS_ENV_DIR" +fi mkdir -p "$GS_ENV_DIR" -# We inject the Refresh Rate here + +echo "Writing to: $GS_ENV_FILE" cat > "$GS_ENV_FILE" < Creating Session Launch Script (Infinite Loop + High Priority)...${C_NC}" +echo -e "${C_BLUE}==> Creating Session Launch Script (Infinite Loop + Safe Priority)...${C_NC}" cat > "$XSESSION_PATH" <<'EOS' #!/bin/bash @@ -150,10 +153,13 @@ cat > "$XSESSION_PATH" <<'EOS' # Redirect logs for debugging exec > >(tee -a "$HOME/.xsession.log") 2>&1 +# Function to handle Wayland socket waiting wait_for_wayland() { local socket_path="$XDG_RUNTIME_DIR/wayland-1" local max_attempts=60 local attempt=1 + + echo "Waiting for Wayland socket at $socket_path" while [ $attempt -le $max_attempts ]; do if [ -e "$socket_path" ] && [ -S "$socket_path" ]; then return 0 @@ -168,6 +174,7 @@ wait_for_wayland() { while true; do echo "--- New Session Cycle Starting ---" + # 1. READ THE NEXT SESSION if [ -f "$HOME/.next-session" ]; then SESSION=$(cat "$HOME/.next-session") rm -f "$HOME/.next-session" @@ -175,34 +182,35 @@ while true; do SESSION="hyprland" fi - # Update DBus for systemd + # 2. UPDATE ENVIRONMENT dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY + # 3. LAUNCH THE SESSION (WITHOUT EXEC) if [[ "$SESSION" == *"gamescope-session-steam"* ]]; then - echo "Starting Gamescope session (High Priority)..." + echo "Starting Gamescope session..." - # Load environment config manually + # --- 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 - # EXPORT VARIABLES + # 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"}" - # --- STUTTER FIX: SYSTEMD-RUN --- - # We wrap the command in systemd-run to give it Real-Time Priority - # This mimics how a real Service would run it, eliminating scheduling latency. - systemd-run --user --scope \ - --property=Nice=-20 \ - --property=Slice=app.slice \ - --unit=gamescope-session-manual \ - gamescope-session-plus steam -- -O DP-1 + # 2. Run blocking, do not exec + # 3. Pass CLI args just in case + gamescope-session-plus steam -- -O DP-1 + # Cleanup unset GAMESCOPECMD unset OUTPUT_CONNECTOR else @@ -211,12 +219,17 @@ while true; do fi fi + # Note: We use a separate 'if' here to catch the fallback above if [[ "$SESSION" != *"gamescope-session-steam"* ]]; then echo "Starting Hyprland session with UWSM..." + + # Run blocking, do not exec uwsm start hyprland-uwsm.desktop fi echo "Session exited. Looping..." + + # 4. CRASH PROTECTION sleep 2 done EOS @@ -303,12 +316,11 @@ mkdir -p "$(dirname "$HYPR_CONF")" if [ ! -f "$HYPR_CONF" ]; then echo "" > "$HYPR_CONF"; fi sed -i '/# Session Switcher Keybinding/d' "$HYPR_CONF" -sed -i '/bind = SUPER, F12, exec,.*switch-session.sh/d' "$HYPR_CONF" +sed -i '/bindd = SUPER, F12, Switch to SteamOS, exec,.*switch-session.sh/d' "$HYPR_CONF" cat >> "$HYPR_CONF" <