feat: Add Gamescope and Sunshine configuration files and update session management
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
OUTPUT_CONNECTOR={{ output_connector }}
|
||||
FRAMERATE={{ framerate }}
|
||||
RESOLUTION={{ screen_resolution }}
|
||||
HDR_ENABLED={{ hdr_enabled }}
|
||||
DRM_DEVICE={{ drm_device }}
|
||||
@@ -1,2 +1,2 @@
|
||||
system_tray=disable
|
||||
log_path = /home/{{ user_name }}/.local/logs/sunshine.log
|
||||
log_path = /home/{{ user_name }}/.local/logs/sunshine.log
|
||||
@@ -4,7 +4,6 @@ LOG_FILE="$HOME/.local/logs/session.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOG_FILE"; }
|
||||
|
||||
|
||||
start_gamescope() {
|
||||
log "Starting Gamescope session..."
|
||||
|
||||
@@ -17,11 +16,11 @@ start_gamescope() {
|
||||
WIDTH="${RESOLUTION%x*}"
|
||||
HEIGHT="${RESOLUTION#*x}"
|
||||
|
||||
export __GL_GSYNC_ALLOWED=1
|
||||
export __GL_VRR_ALLOWED=1
|
||||
# export __GL_THREADED_OPTIMIZATIONS=1
|
||||
export __GL_SHADER_DISK_CACHE=1
|
||||
export __GL_SYNC_TO_VBLANK=0
|
||||
# export __GL_GSYNC_ALLOWED=1
|
||||
# export __GL_VRR_ALLOWED=1
|
||||
# # export __GL_THREADED_OPTIMIZATIONS=1
|
||||
# export __GL_SHADER_DISK_CACHE=1
|
||||
# export __GL_SYNC_TO_VBLANK=0
|
||||
|
||||
GAMESCOPE_BIN="$(command -v gamescope || true)"
|
||||
if [ -z "$GAMESCOPE_BIN" ]; then
|
||||
@@ -37,9 +36,28 @@ start_gamescope() {
|
||||
log "HDR disabled, no HDR flag added"
|
||||
fi
|
||||
|
||||
GAMESCOPE_ARGS="--generate-drm-mode fixed --fade-out-duration 200 --cursor-scale-height 720 -f -w $WIDTH -h $HEIGHT --rt --mangoapp -e -O \"$OUTPUT_CONNECTOR\" -r $FRAMERATE $HDR_FLAG"
|
||||
log "Launching Gamescope: $GAMESCOPE_BIN $GAMESCOPE_ARGS -- $@"
|
||||
exec dbus-run-session -- "$GAMESCOPE_BIN" ${GAMESCOPE_ARGS} -- "$@" >>"$LOG_FILE" 2>&1
|
||||
# Build gamescope argument array for safe quoting and readability
|
||||
GAMESCOPE_ARGS=(
|
||||
--generate-drm-mode fixed
|
||||
--fade-out-duration 200
|
||||
--cursor-scale-height 720
|
||||
-f
|
||||
-W "$WIDTH" -H "$HEIGHT"
|
||||
-w "$WIDTH" -h "$HEIGHT"
|
||||
--rt --mangoapp -e
|
||||
-O "$OUTPUT_CONNECTOR"
|
||||
-r "$FRAMERATE"
|
||||
)
|
||||
|
||||
# Append HDR flag if enabled
|
||||
if [ -n "${HDR_FLAG:-}" ]; then
|
||||
GAMESCOPE_ARGS+=("$HDR_FLAG")
|
||||
fi
|
||||
|
||||
log "Launching Gamescope: $GAMESCOPE_BIN ${GAMESCOPE_ARGS[*]} -- $*"
|
||||
|
||||
# Execute gamescope inside a DBus session, preserving proper argument quoting
|
||||
exec dbus-run-session -- "$GAMESCOPE_BIN" "${GAMESCOPE_ARGS[@]}" -- "$@" >>"$LOG_FILE" 2>&1
|
||||
}
|
||||
|
||||
start_kwin() {
|
||||
@@ -64,6 +82,11 @@ start_kwin() {
|
||||
exec dbus-run-session -- "$KWIN_BIN" ${KWIN_ARGS} "$@" >>"$LOG_FILE" 2>&1
|
||||
}
|
||||
|
||||
|
||||
export XDG_SEAT=seat0
|
||||
export XDG_RUNTIME_DIR=/run/user/$(id -u)
|
||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
|
||||
|
||||
if [[ -f "$HOME/.desktop-session-plasma" ]]; then
|
||||
log "Plasma session selected."
|
||||
rm "$HOME/.desktop-session-plasma"
|
||||
|
||||
@@ -101,9 +101,6 @@ log "Updating steam: /opt/steamcmd/steamcmd.sh +quit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
log "Updating Steam ROM Manager"
|
||||
srm add >> "$LOGFILE" 2>&1 || log "ERROR: Steam ROM Manager update failed"
|
||||
|
||||
log "Launching Steam"
|
||||
STEAM_ARGS=("-steamdeck" "-steamos3" "-steampal" "-gamepadui" "-pipewire-dmabuf")
|
||||
systemd-run --user --scope --quiet \
|
||||
|
||||
@@ -37,4 +37,4 @@ if systemctl --user is-active --quiet sunshine.scope; then
|
||||
fi
|
||||
|
||||
log "Restarting graphical session service..."
|
||||
sudo systemctl restart gamescope-session.service
|
||||
systemctl --user restart session.service
|
||||
@@ -1,29 +0,0 @@
|
||||
[Unit]
|
||||
Description=Weston Wayland compositor for user gameuser
|
||||
Wants=graphical.target
|
||||
Conflicts=getty@tty1.service
|
||||
After=getty@tty1.service
|
||||
After=rc-local.service plymouth-start.service systemd-user-sessions.service
|
||||
|
||||
[Service]
|
||||
Slice=gamescope.slice
|
||||
User=gameuser
|
||||
PAMName=login
|
||||
TTYPath=/dev/tty1
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
StandardInput=tty
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
UtmpIdentifier=tty1
|
||||
UtmpMode=user
|
||||
Environment=XDG_SEAT=seat0
|
||||
Environment=XDG_RUNTIME_DIR=/run/user/%U
|
||||
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%U/bus
|
||||
ExecStartPre=/usr/bin/chvt 1
|
||||
ExecStart=/usr/bin/bash /usr/local/bin/launch_session.sh
|
||||
Restart=always
|
||||
KeyringMode=shared
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
@@ -1,3 +0,0 @@
|
||||
[Slice]
|
||||
CPUWeight=100
|
||||
AllowedCPUs={{ general_cores }}
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=User session service
|
||||
After=graphical-session.target systemd-user-sessions.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/bash /usr/local/bin/launch_session.sh
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/update_roms.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
ROM_MANAGER_BIN="$(command -v srm || true)"
|
||||
if [ -z "$ROM_MANAGER_BIN" ]; then
|
||||
log "ERROR: srm (Steam ROM Manager) not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
log "Updating Steam ROM Manager"
|
||||
$ROM_MANAGER_BIN add >> "$LOGFILE" 2>&1 || {
|
||||
log "ERROR: Steam ROM Manager update failed"
|
||||
exit 1
|
||||
}
|
||||
log "Steam ROM Manager update completed successfully, restarting Steam service if running"
|
||||
if systemctl --user is-active --quiet steam.scope; then
|
||||
log "Restarting Steam service to apply changes"
|
||||
systemctl --user restart steam.scope
|
||||
log "Steam service restarted"
|
||||
else
|
||||
log "Steam service is not running, no need to restart"
|
||||
fi
|
||||
Reference in New Issue
Block a user