feat: Add configuration and scripts for Sunshine and Gamescope integration

This commit is contained in:
2025-10-28 00:04:17 +01:00
parent 49de842b57
commit 9fa68f3bc5
11 changed files with 207 additions and 76 deletions
@@ -3,6 +3,8 @@ set -euo pipefail
LOGFILE="$HOME/.local/logs/steam.log"
export PATH="$HOME/.local/bin:$PATH"
export XDG_RUNTIME_DIR=/run/user/$(id -u)
export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0
# There is no way to set a color space for an NV12
@@ -62,6 +64,9 @@ export XCURSOR_SCALE=256
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
mkdir -p $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR
if [ -r /proc/sys/user/max_user_namespaces ]; then
max_ns="$(cat /proc/sys/user/max_user_namespaces || echo 0)"
if [ "${max_ns:-0}" -eq 0 ]; then
@@ -99,14 +104,39 @@ log "Updating steam: /opt/steamcmd/steamcmd.sh +quit"
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")
log "Launching Steam: $STEAM_BIN ${STEAM_ARGS[*]}"
exec $STEAM_BIN "${STEAM_ARGS[@]}" &
systemd-run --user --scope --quiet \
--unit=steam.scope \
--slice=steam.slice \
"$STEAM_BIN" "${STEAM_ARGS[@]}" >>"$LOGFILE" 2>&1 &
steam_scope_pid=$!
log "Steam started with pid $steam_scope_pid"
sleep 5
systemd-run --user --slice=sunshine.slice --scope sunshine >>"$LOGFILE" 2>&1 || {
log "ERROR: Failed to start Sunshine"
exit 1
{
SUNSHINE_BIN="$(command -v sunshine || true)"
if [ -z "$SUNSHINE_BIN" ]; then
log "ERROR: sunshine not found in PATH"
else
SUNSHINE_LOG_FILE="$HOME/.local/logs/sunshine.log"
log "Found Sunshine: $SUNSHINE_BIN, starting after 5s delay"
sleep 5
systemd-run --user --scope --quiet \
--unit=sunshine.scope \
--slice=sunshine.slice \
"$SUNSHINE_BIN" "$HOME/.config/sunshine/sunshine.conf"
fi
} &
tail -f /dev/null
# Wait for Steam to exit
wait "$steam_scope_pid"
status=$?
# Stop Sunshine gracefully
if systemctl --user is-active --quiet sunshine.scope; then
log "Stopping Sunshine"
systemctl --user stop sunshine.scope
fi
log "Steam session ended."
exit "$status"