|
|
@@ -1,7 +1,7 @@
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Seamless Hyprland <-> Gamescope Session Switcher for Arch Linux
|
|
|
|
# Seamless Hyprland <-> Gamescope Session Switcher for Arch Linux
|
|
|
|
# Updated: Walker, Infinite Loop, env.d Config, Color Reset, IWD Backend
|
|
|
|
# Updated: Clean Config, User Inputs for HDR/VRR
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -e
|
|
|
@@ -19,20 +19,67 @@ if [ "$EUID" -eq 0 ]; then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
USER_NAME=$(whoami)
|
|
|
|
USER_NAME=$(whoami)
|
|
|
|
USER_HOME=$(eval echo "~$USER_NAME")
|
|
|
|
USER_HOME=$HOME
|
|
|
|
|
|
|
|
|
|
|
|
# --- Banner ---
|
|
|
|
# --- Banner ---
|
|
|
|
echo -e "${C_BLUE}===================================================================${C_NC}"
|
|
|
|
echo -e "${C_BLUE}===================================================================${C_NC}"
|
|
|
|
echo -e "${C_BLUE} Hyprland <-> Gamescope Session Switcher Setup for: ${C_YELLOW}$USER_NAME${C_NC}"
|
|
|
|
echo -e "${C_BLUE} Hyprland <-> Gamescope Session Switcher Setup for: ${C_YELLOW}$USER_NAME${C_NC}"
|
|
|
|
echo -e "${C_BLUE}===================================================================${C_NC}\n"
|
|
|
|
echo -e "${C_BLUE}===================================================================${C_NC}\n"
|
|
|
|
|
|
|
|
|
|
|
|
# --- USER CHOICE FOR AUTOLOGIN ---
|
|
|
|
# --- USER INPUTS ---
|
|
|
|
echo -e "${C_YELLOW}Configuration Choice:${C_NC}"
|
|
|
|
echo -e "${C_YELLOW}Configuration Choice:${C_NC}"
|
|
|
|
echo "Do you want to enable automatic login? [y/N]: "
|
|
|
|
echo "Do you want to enable automatic login? [y/N]: "
|
|
|
|
read AUTOLOGIN_CHOICE
|
|
|
|
read AUTOLOGIN_CHOICE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "\n${C_YELLOW}Monitor Configuration:${C_NC}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
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 ---
|
|
|
|
# --- 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"
|
|
|
|
SWITCH_SCRIPT_PATH="$USER_HOME/.local/bin/switch-session.sh"
|
|
|
|
XSESSION_PATH="$USER_HOME/.xsession"
|
|
|
|
XSESSION_PATH="$USER_HOME/.xsession"
|
|
|
|
SERVICE_OVERRIDE_DIR="/etc/systemd/user/gamescope-session-plus@.service.d"
|
|
|
|
SERVICE_OVERRIDE_DIR="/etc/systemd/user/gamescope-session-plus@.service.d"
|
|
|
@@ -40,9 +87,8 @@ SERVICE_OVERRIDE_FILE="$SERVICE_OVERRIDE_DIR/override.conf"
|
|
|
|
GS_ENV_DIR="$USER_HOME/.config/environment.d"
|
|
|
|
GS_ENV_DIR="$USER_HOME/.config/environment.d"
|
|
|
|
GS_ENV_FILE="$GS_ENV_DIR/gamescope-session-plus.conf"
|
|
|
|
GS_ENV_FILE="$GS_ENV_DIR/gamescope-session-plus.conf"
|
|
|
|
|
|
|
|
|
|
|
|
# UPDATED: Removed wofi, added walker to AUR packages
|
|
|
|
|
|
|
|
OFFICIAL_PACKAGES=( "hyprland" "sddm" "uwsm" "networkmanager" )
|
|
|
|
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
|
|
|
|
# STEP 1: DEPENDENCY INSTALLATION
|
|
|
@@ -75,30 +121,73 @@ EOF
|
|
|
|
systemctl --user daemon-reload
|
|
|
|
systemctl --user daemon-reload
|
|
|
|
|
|
|
|
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
# STEP 4: CONFIGURE GAMESCOPE ENVIRONMENT (MONITOR FIX)
|
|
|
|
# STEP 3.5: GRANT REAL-TIME PRIORITY CAPABILITIES
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
echo -e "${C_BLUE}==> Configuring Gamescope Monitor Settings (DP-1)...${C_NC}"
|
|
|
|
echo -e "${C_BLUE}==> Granting CAP_SYS_NICE to Gamescope...${C_NC}"
|
|
|
|
echo "Writing to: $GS_ENV_FILE"
|
|
|
|
# This allows gamescope to use --rt (realtime) scheduling without root
|
|
|
|
mkdir -p "$GS_ENV_DIR"
|
|
|
|
GAME_BIN=$(which gamescope)
|
|
|
|
cat > "$GS_ENV_FILE" <<EOF
|
|
|
|
if [ -f "$GAME_BIN" ]; then
|
|
|
|
# Force Output to DP-1 (Fixes display issue)
|
|
|
|
sudo setcap 'CAP_SYS_NICE=eip' "$GAME_BIN"
|
|
|
|
OUTPUT_CONNECTOR=DP-1
|
|
|
|
echo -e "${C_GREEN}Capability set on $GAME_BIN${C_NC}"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo -e "${C_RED}Error: Gamescope binary not found!${C_NC}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Force specific arguments for gamescope-session-plus
|
|
|
|
#=======================================================
|
|
|
|
GAMESCOPE_ARGS="-O DP-1 --steam -e"
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# --- 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
# STEP 5: CONFIGURE NETWORK MANAGER (IWD BACKEND)
|
|
|
|
# STEP 5: CONFIGURE NETWORK MANAGER (IWD BACKEND)
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
echo -e "${C_BLUE}==> Configuring NetworkManager for SteamOS compatibility...${C_NC}"
|
|
|
|
echo -e "${C_BLUE}==> Configuring NetworkManager for SteamOS compatibility...${C_NC}"
|
|
|
|
# Create config to use iwd backend (prevents conflicts)
|
|
|
|
|
|
|
|
sudo mkdir -p /etc/NetworkManager/conf.d
|
|
|
|
sudo mkdir -p /etc/NetworkManager/conf.d
|
|
|
|
sudo tee /etc/NetworkManager/conf.d/wifi_backend.conf > /dev/null <<EOF
|
|
|
|
sudo tee /etc/NetworkManager/conf.d/wifi_backend.conf > /dev/null <<EOF
|
|
|
|
[device]
|
|
|
|
[device]
|
|
|
|
wifi.backend=iwd
|
|
|
|
wifi.backend=iwd
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
echo "Enabling NetworkManager..."
|
|
|
|
echo "Enabling NetworkManager..."
|
|
|
|
sudo systemctl enable NetworkManager
|
|
|
|
sudo systemctl enable NetworkManager
|
|
|
|
|
|
|
|
|
|
|
@@ -107,7 +196,6 @@ sudo systemctl enable NetworkManager
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
echo -e "${C_BLUE}==> Installing Session Switching Workflow...${C_NC}"
|
|
|
|
echo -e "${C_BLUE}==> Installing Session Switching Workflow...${C_NC}"
|
|
|
|
|
|
|
|
|
|
|
|
# --- SDDM AUTOLOGIN (CONDITIONAL) ---
|
|
|
|
|
|
|
|
if [[ "$AUTOLOGIN_CHOICE" =~ ^[Yy]$ ]]; then
|
|
|
|
if [[ "$AUTOLOGIN_CHOICE" =~ ^[Yy]$ ]]; then
|
|
|
|
echo "--> Configuring SDDM for autologin..."
|
|
|
|
echo "--> Configuring SDDM for autologin..."
|
|
|
|
sudo tee /etc/sddm.conf > /dev/null <<EOF
|
|
|
|
sudo tee /etc/sddm.conf > /dev/null <<EOF
|
|
|
@@ -121,7 +209,6 @@ else
|
|
|
|
AUTOLOGIN_ENABLED=false
|
|
|
|
AUTOLOGIN_ENABLED=false
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# --- WAYLAND SESSION DESKTOP ENTRY ---
|
|
|
|
|
|
|
|
sudo tee /usr/share/wayland-sessions/switcher.desktop > /dev/null <<EOF
|
|
|
|
sudo tee /usr/share/wayland-sessions/switcher.desktop > /dev/null <<EOF
|
|
|
|
[Desktop Entry]
|
|
|
|
[Desktop Entry]
|
|
|
|
Name=Auto Session Switcher
|
|
|
|
Name=Auto Session Switcher
|
|
|
@@ -132,7 +219,7 @@ EOF
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
# STEP 7: CREATE XSESSION LAUNCH SCRIPT (THE LOOP)
|
|
|
|
# STEP 7: CREATE XSESSION LAUNCH SCRIPT (THE LOOP)
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
echo -e "${C_BLUE}==> Creating Session Launch Script (Infinite Loop)...${C_NC}"
|
|
|
|
echo -e "${C_BLUE}==> Creating Session Launch Script (Infinite Loop + Safe Priority)...${C_NC}"
|
|
|
|
|
|
|
|
|
|
|
|
cat > "$XSESSION_PATH" <<'EOS'
|
|
|
|
cat > "$XSESSION_PATH" <<'EOS'
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/bash
|
|
|
@@ -176,12 +263,26 @@ while true; do
|
|
|
|
if [[ "$SESSION" == *"gamescope-session-steam"* ]]; then
|
|
|
|
if [[ "$SESSION" == *"gamescope-session-steam"* ]]; then
|
|
|
|
echo "Starting Gamescope session..."
|
|
|
|
echo "Starting Gamescope session..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --- LOAD USER CONFIG FROM ENVIRONMENT.D ---
|
|
|
|
|
|
|
|
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
|
|
|
|
# Check for the executable
|
|
|
|
if command -v gamescope-session-plus &> /dev/null; then
|
|
|
|
if command -v gamescope-session-plus &> /dev/null; then
|
|
|
|
# Run blocking, do not exec
|
|
|
|
|
|
|
|
export GAMESCOPECMD="/usr/bin/gamescope -O DP-1 --steam -e --"
|
|
|
|
# Use the constructed variable from the conf file
|
|
|
|
gamescope-session-plus steam
|
|
|
|
echo "Executing Command: $GAMESCOPECMD"
|
|
|
|
unset GAMESCOPECMD
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "Error: gamescope-session-plus not found, falling back to Hyprland"
|
|
|
|
echo "Error: gamescope-session-plus not found, falling back to Hyprland"
|
|
|
|
SESSION="hyprland"
|
|
|
|
SESSION="hyprland"
|
|
|
@@ -201,7 +302,6 @@ while true; do
|
|
|
|
# 4. CRASH PROTECTION
|
|
|
|
# 4. CRASH PROTECTION
|
|
|
|
sleep 2
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
EOS
|
|
|
|
EOS
|
|
|
|
chmod +x "$XSESSION_PATH"
|
|
|
|
chmod +x "$XSESSION_PATH"
|
|
|
|
|
|
|
|
|
|
|
@@ -212,34 +312,25 @@ echo -e "${C_BLUE}==> Creating Session Switching Helper...${C_NC}"
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "$(dirname "$SWITCH_SCRIPT_PATH")"
|
|
|
|
mkdir -p "$(dirname "$SWITCH_SCRIPT_PATH")"
|
|
|
|
cat > "$SWITCH_SCRIPT_PATH" <<'EOSWITCH'
|
|
|
|
cat > "$SWITCH_SCRIPT_PATH" <<'EOSWITCH'
|
|
|
|
|
|
|
|
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-1}"
|
|
|
|
export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-1}"
|
|
|
|
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
|
|
|
|
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
|
|
|
|
|
|
|
|
|
|
|
|
choice=$(printf "🎮 SteamOS" | walker --dmenu \
|
|
|
|
# Walker in dmenu mode
|
|
|
|
--placeholder "Switch Mode:" \
|
|
|
|
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
|
|
|
|
case "$choice" in
|
|
|
|
"🎮 SteamOS")
|
|
|
|
"🎮 SteamOS")
|
|
|
|
# Validate we can write the session file
|
|
|
|
notify-send "Session Switcher" "Disabling Night Light..." -t 1000
|
|
|
|
|
|
|
|
pkill hyprsunset
|
|
|
|
|
|
|
|
pkill wlsunset
|
|
|
|
|
|
|
|
pkill gammastep
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
if echo "gamescope-session-steam.desktop" > "$HOME/.next-session" 2>/dev/null; then
|
|
|
|
if echo "gamescope-session-steam.desktop" > "$HOME/.next-session" 2>/dev/null; then
|
|
|
|
notify-send "Session Switcher" "Switching to SteamOS..." -t 2000
|
|
|
|
notify-send "Session Switcher" "Switching to SteamOS..." -t 2000
|
|
|
|
echo "Session file written successfully"
|
|
|
|
|
|
|
|
pkill hyprsunset
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
notify-send "Session Switcher" "Error: Failed to write session file" -t 3000
|
|
|
|
notify-send "Session Switcher" "Error: Failed to write session file" -t 3000
|
|
|
|
echo "Error: Cannot write to $HOME/.next-session"
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
@@ -249,75 +340,40 @@ case "$choice" in
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Improved session cleanup with better reliability
|
|
|
|
|
|
|
|
cleanup_session() {
|
|
|
|
cleanup_session() {
|
|
|
|
local max_wait=5
|
|
|
|
local max_wait=5
|
|
|
|
local wait_count=0
|
|
|
|
local wait_count=0
|
|
|
|
|
|
|
|
|
|
|
|
# Detect current session more reliably
|
|
|
|
|
|
|
|
if pgrep -x "gamescope" > /dev/null || pgrep -f "gamescope-session" > /dev/null; then
|
|
|
|
if pgrep -x "gamescope" > /dev/null || pgrep -f "gamescope-session" > /dev/null; then
|
|
|
|
echo "Detected Gamescope session, shutting down..."
|
|
|
|
echo "Detected Gamescope session, shutting down..."
|
|
|
|
|
|
|
|
|
|
|
|
# Try graceful shutdown first
|
|
|
|
|
|
|
|
systemctl --user stop gamescope-session-plus@steam 2>/dev/null || true
|
|
|
|
systemctl --user stop gamescope-session-plus@steam 2>/dev/null || true
|
|
|
|
sleep 1
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
|
|
|
|
# Force kill if still running
|
|
|
|
|
|
|
|
if pgrep -x "gamescope" > /dev/null; then
|
|
|
|
if pgrep -x "gamescope" > /dev/null; then
|
|
|
|
pkill -TERM gamescope
|
|
|
|
pkill -TERM gamescope
|
|
|
|
sleep 0.5
|
|
|
|
sleep 0.5
|
|
|
|
pkill -KILL gamescope 2>/dev/null || true
|
|
|
|
pkill -KILL gamescope 2>/dev/null || true
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
elif [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] || pgrep -x "Hyprland" > /dev/null; then
|
|
|
|
echo "Detected Hyprland session, shutting down..."
|
|
|
|
echo "Detected Hyprland session, shutting down..."
|
|
|
|
|
|
|
|
|
|
|
|
# Try hyprctl first if available
|
|
|
|
|
|
|
|
if command -v hyprctl &> /dev/null && [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ]; then
|
|
|
|
if command -v hyprctl &> /dev/null && [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ]; then
|
|
|
|
hyprctl dispatch exit 2>/dev/null || true
|
|
|
|
hyprctl dispatch exit 2>/dev/null || true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# Fallback to pkill
|
|
|
|
|
|
|
|
pkill -TERM Hyprland 2>/dev/null || true
|
|
|
|
pkill -TERM Hyprland 2>/dev/null || true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
|
|
|
|
# Force kill if still running
|
|
|
|
|
|
|
|
if pgrep -x "Hyprland" > /dev/null; then
|
|
|
|
if pgrep -x "Hyprland" > /dev/null; then
|
|
|
|
pkill -KILL Hyprland 2>/dev/null || true
|
|
|
|
pkill -KILL Hyprland 2>/dev/null || true
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
else
|
|
|
|
echo "No specific session detected, attempting general cleanup..."
|
|
|
|
|
|
|
|
# Fallback cleanup
|
|
|
|
|
|
|
|
pkill -u $USER Hyprland 2>/dev/null || true
|
|
|
|
pkill -u $USER Hyprland 2>/dev/null || true
|
|
|
|
pkill -u $USER gamescope 2>/dev/null || true
|
|
|
|
pkill -u $USER gamescope 2>/dev/null || true
|
|
|
|
systemctl --user stop gamescope-session-plus@steam 2>/dev/null || true
|
|
|
|
systemctl --user stop gamescope-session-plus@steam 2>/dev/null || true
|
|
|
|
sleep 1
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Clean up any remaining compositor processes
|
|
|
|
|
|
|
|
pkill -u $USER -f "gamescope-session" 2>/dev/null || true
|
|
|
|
pkill -u $USER -f "gamescope-session" 2>/dev/null || true
|
|
|
|
pkill -u $USER -f "steam" 2>/dev/null || true
|
|
|
|
pkill -u $USER -f "steam" 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
|
|
# Give time for cleanup
|
|
|
|
|
|
|
|
sleep 0.5
|
|
|
|
sleep 0.5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Execute cleanup
|
|
|
|
|
|
|
|
cleanup_session
|
|
|
|
cleanup_session
|
|
|
|
EOSWITCH
|
|
|
|
EOSWITCH
|
|
|
|
chmod +x "$SWITCH_SCRIPT_PATH"
|
|
|
|
chmod +x "$SWITCH_SCRIPT_PATH"
|
|
|
@@ -326,43 +382,25 @@ chmod +x "$SWITCH_SCRIPT_PATH"
|
|
|
|
# STEP 9: CONFIGURE HYPRLAND KEYBINDING
|
|
|
|
# STEP 9: CONFIGURE HYPRLAND KEYBINDING
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
echo -e "${C_BLUE}==> Configuring Hyprland Keybinding...${C_NC}"
|
|
|
|
echo -e "${C_BLUE}==> Configuring Hyprland Keybinding...${C_NC}"
|
|
|
|
|
|
|
|
|
|
|
|
# Create hyprland config directory if it doesn't exist
|
|
|
|
|
|
|
|
mkdir -p "$(dirname "$HYPR_CONF")"
|
|
|
|
mkdir -p "$(dirname "$HYPR_CONF")"
|
|
|
|
|
|
|
|
if [ ! -f "$HYPR_CONF" ]; then echo "" > "$HYPR_CONF"; fi
|
|
|
|
if [ ! -f "$HYPR_CONF" ]; then
|
|
|
|
|
|
|
|
echo "# Hyprland Configuration" > "$HYPR_CONF"
|
|
|
|
|
|
|
|
echo "" >> "$HYPR_CONF"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sed -i '/# Session Switcher Keybinding/d' "$HYPR_CONF"
|
|
|
|
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" <<EOF
|
|
|
|
cat >> "$HYPR_CONF" <<EOF
|
|
|
|
|
|
|
|
|
|
|
|
# Session Switcher Keybinding
|
|
|
|
# Session Switcher Keybinding
|
|
|
|
bind = SUPER, F12, exec, $SWITCH_SCRIPT_PATH
|
|
|
|
bindd = SUPER, F12, Switch to SteamOS, exec, $SWITCH_SCRIPT_PATH
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "${C_GREEN}Added SUPER+F12 keybinding to $HYPR_CONF${C_NC}"
|
|
|
|
echo -e "${C_GREEN}Added SUPER+F12 keybinding to $HYPR_CONF${C_NC}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
# FINALIZATION
|
|
|
|
# FINALIZATION
|
|
|
|
#=======================================================
|
|
|
|
#=======================================================
|
|
|
|
echo -e "${C_GREEN}✅ Setup Complete! ✅${C_NC}\n"
|
|
|
|
echo -e "${C_GREEN}✅ Setup Complete! ✅${C_NC}\n"
|
|
|
|
|
|
|
|
echo -e "${C_YELLOW}Restored Functionality:${C_NC}"
|
|
|
|
echo -e "${C_YELLOW}Important Fixes Applied:${C_NC}"
|
|
|
|
echo "1. REMOVED systemd-run wrapper (it was causing permissions crashes)."
|
|
|
|
echo "1. REPLACED 'wofi' with 'walker'."
|
|
|
|
echo "2. ADDED safe priority boost (renice) for smoother performance."
|
|
|
|
echo "2. CONFIGURED NetworkManager to use 'iwd' backend."
|
|
|
|
echo "3. FIXED environment.d directory creation error."
|
|
|
|
echo "3. UPDATED '.xsession' to use an infinite loop (prevents logout)."
|
|
|
|
echo -e "\n${C_YELLOW}Run this script, then REBOOT.${C_NC}\n"
|
|
|
|
echo "4. CREATED '~/.config/environment.d/gamescope-session-plus.conf' to force DP-1."
|
|
|
|
|
|
|
|
echo "5. MODIFIED Switch script to kill 'hyprsunset' before switching."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "\n${C_YELLOW}A REBOOT IS REQUIRED to activate NetworkManager and the new Session structure.${C_NC}\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$AUTOLOGIN_ENABLED" = true ]; then
|
|
|
|
|
|
|
|
echo -e "-> Autologin is enabled. System will boot directly into Hyprland."
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo -e "-> Autologin is disabled. Choose 'Auto Session Switcher' at login."
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|