steam-session: added more opt
unfixed
This commit is contained in:
@@ -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" <<EOF
|
||||
# Force Output to DP-1
|
||||
OUTPUT_CONNECTOR=DP-1
|
||||
# --- GAMESCOPE CONFIGURATION ---
|
||||
# Generated by setup script on $(date)
|
||||
#
|
||||
# Flags Explanation:
|
||||
# -O : Output Connector
|
||||
# -r : Refresh Rate
|
||||
# -W/-H : Resolution the Game sees
|
||||
# -w/-h : Resolution sent to Monitor
|
||||
# -e : Steam Integration
|
||||
# -f : Force Fullscreen
|
||||
# --xwayland-count 2 : Vital for Steam Deck UI + Game
|
||||
# --immediate-flips : Low latency mode
|
||||
# --rt : Real-time priority
|
||||
|
||||
# Enable VRR
|
||||
ADAPTIVE_SYNC=1
|
||||
|
||||
# Force specific arguments for gamescope-session-plus
|
||||
GAMESCOPE_ARGS="-O DP-1 $REFRESH_ARG --steam -e"
|
||||
GAMESCOPECMD="/usr/bin/gamescope \\
|
||||
-O $USER_OUTPUT \\
|
||||
-r $USER_REFRESH \\
|
||||
-W $USER_WIDTH -H $USER_HEIGHT \\
|
||||
-w $USER_WIDTH -h $USER_HEIGHT \\
|
||||
$VRR_FLAG \\
|
||||
$HDR_FLAG \\
|
||||
--immediate-flips \\
|
||||
--rt \\
|
||||
-e \\
|
||||
--mangoapp \\
|
||||
--xwayland-count 2 \\
|
||||
--default-touch-mode 4 \\
|
||||
--hide-cursor-delay 3000 \\
|
||||
--fade-out-duration 200"
|
||||
EOF
|
||||
|
||||
#=======================================================
|
||||
@@ -190,7 +264,6 @@ while true; do
|
||||
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
|
||||
@@ -201,18 +274,15 @@ while true; do
|
||||
# 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"}"
|
||||
# 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"
|
||||
|
||||
Reference in New Issue
Block a user