From 47ccb71a0d9d62b8b1115fe2672cd9ed38cb4cd9 Mon Sep 17 00:00:00 2001 From: kenji Date: Wed, 3 Dec 2025 15:05:14 -0600 Subject: [PATCH] steam-session: added more opt unfixed --- scripts/Hyperland-Steamos/install.sh | 132 ++++++++++++++++++++------- 1 file changed, 101 insertions(+), 31 deletions(-) diff --git a/scripts/Hyperland-Steamos/install.sh b/scripts/Hyperland-Steamos/install.sh index 554fd8e..0e618e2 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: Restore Functionality, Safe Priority Boost, Directory Fix +# Updated: Clean Config, User Inputs for HDR/VRR # set -e @@ -32,13 +32,52 @@ echo "Do you want to enable automatic login? [y/N]: " read AUTOLOGIN_CHOICE echo -e "\n${C_YELLOW}Monitor Configuration:${C_NC}" -echo "Enter your Refresh Rate (e.g., 60, 144, 165). Leave empty for auto:" + +# 1. Output Port +echo "Enter your Output Connector (default: DP-1):" +read USER_OUTPUT +USER_OUTPUT=${USER_OUTPUT:-DP-1} + +# 2. Width +echo "Enter Screen Width (default: 3440):" +read USER_WIDTH +USER_WIDTH=${USER_WIDTH:-3440} + +# 3. Height +echo "Enter Screen Height (default: 1440):" +read USER_HEIGHT +USER_HEIGHT=${USER_HEIGHT:-1440} + +# 4. Refresh Rate +echo "Enter Refresh Rate (default: 180):" read USER_REFRESH -REFRESH_ARG="" -if [ -n "$USER_REFRESH" ]; then - REFRESH_ARG="-r $USER_REFRESH" +USER_REFRESH=${USER_REFRESH:-180} + +# 5. VRR (Adaptive Sync) +echo "Enable VRR / Adaptive Sync? [Y/n] (Default: Yes)" +read USER_VRR +if [[ "$USER_VRR" =~ ^[Nn]$ ]]; then + VRR_FLAG="" + echo -e "-> VRR Disabled" +else + VRR_FLAG="--adaptive-sync" + echo -e "-> VRR Enabled" fi +# 6. HDR +echo "Enable HDR? [Y/n] (Default: Yes)" +read USER_HDR +if [[ "$USER_HDR" =~ ^[Nn]$ ]]; then + HDR_FLAG="" + echo -e "-> HDR Disabled" +else + HDR_FLAG="--hdr-enabled" + echo -e "-> HDR Enabled" +fi + +echo -e "${C_GREEN}Configured: ${USER_OUTPUT} @ ${USER_WIDTH}x${USER_HEIGHT} (${USER_REFRESH}Hz)${C_NC}\n" + + # --- Script Variables --- HYPR_CONF="$USER_HOME/.config/hypr/bindings.conf" SWITCH_SCRIPT_PATH="$USER_HOME/.local/bin/switch-session.sh" @@ -49,7 +88,7 @@ GS_ENV_DIR="$USER_HOME/.config/environment.d" GS_ENV_FILE="$GS_ENV_DIR/gamescope-session-plus.conf" OFFICIAL_PACKAGES=( "hyprland" "sddm" "uwsm" "networkmanager" ) -AUR_PACKAGES=( "gamescope-git" "gamescope-session-git" "steam" "gamescope-session-steam-git" "mangohud" "walker" ) +AUR_PACKAGES=( "gamescope-git" "gamescope-session-git" "steam" "gamescope-session-steam-git" "walker" ) #======================================================= # STEP 1: DEPENDENCY INSTALLATION @@ -82,27 +121,62 @@ EOF systemctl --user daemon-reload #======================================================= -# STEP 4: CONFIGURE GAMESCOPE ENVIRONMENT +# STEP 3.5: GRANT REAL-TIME PRIORITY CAPABILITIES #======================================================= -echo -e "${C_BLUE}==> Configuring Gamescope Monitor Settings (DP-1)...${C_NC}" - -# 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" +echo -e "${C_BLUE}==> Granting CAP_SYS_NICE to Gamescope...${C_NC}" +# This allows gamescope to use --rt (realtime) scheduling without root +GAME_BIN=$(which gamescope) +if [ -f "$GAME_BIN" ]; then + sudo setcap 'CAP_SYS_NICE=eip' "$GAME_BIN" + echo -e "${C_GREEN}Capability set on $GAME_BIN${C_NC}" +else + echo -e "${C_RED}Error: Gamescope binary not found!${C_NC}" fi + +#======================================================= +# STEP 4: CONFIGURE GAMESCOPE ENVIRONMENT (CLEAN) +#======================================================= +echo -e "${C_BLUE}==> Configuring Gamescope Command...${C_NC}" + +if [ -f "$GS_ENV_DIR" ]; then rm "$GS_ENV_DIR"; fi mkdir -p "$GS_ENV_DIR" echo "Writing to: $GS_ENV_FILE" + +# NOTE: We do NOT use quotes around EOF here. +# This allows the variables ($USER_OUTPUT, $VRR_FLAG, etc.) to expanded +# RIGHT NOW, so the resulting file contains only hardcoded values. + cat > "$GS_ENV_FILE" < /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"}" + # Use the constructed variable from the conf file + echo "Executing Command: $GAMESCOPECMD" - # 2. Run blocking, do not exec - # 3. Pass CLI args just in case - gamescope-session-plus steam -- -O DP-1 + # Strip the leading binary path to get just the args + # We strip "/usr/bin/gamescope" OR just "gamescope" to be safe + ARGS=$(echo "$GAMESCOPECMD" | sed 's|^/usr/bin/gamescope ||' | sed 's|^gamescope ||') + + gamescope-session-plus steam -- $ARGS - # Cleanup - unset GAMESCOPECMD - unset OUTPUT_CONNECTOR else echo "Error: gamescope-session-plus not found, falling back to Hyprland" SESSION="hyprland"