feat: Add configuration and scripts for Sunshine and Gamescope integration
This commit is contained in:
@@ -5,19 +5,64 @@ export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
DESKTOP_BIN="$(command -v startplasma-wayland || true)"
|
||||
DESKTOP_BIN="$(command -v plasmashell || true)"
|
||||
if [ -z "$DESKTOP_BIN" ]; then
|
||||
log "ERROR: startplasma-wayland not found in PATH"
|
||||
log "ERROR: plasmashell not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
log "Launching Plasma: $DESKTOP_BIN"
|
||||
exec $DESKTOP_BIN >>"$LOGFILE" 2>&1 &
|
||||
export XDG_CURRENT_DESKTOP=plasma
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
export XDG_DATA_DIRS=/usr/local/share/:/usr/share/
|
||||
export XDG_CONFIG_DIRS=/usr/local/etc/xdg:/etc/xdg
|
||||
export XDG_CURRENT_DESKTOP=KDE
|
||||
export XDG_RUNTIME_DIR=/run/user/$(id -u)
|
||||
|
||||
sleep 5
|
||||
systemd-run --user --slice=sunshine.slice --scope sunshine >>"$LOGFILE" 2>&1 || {
|
||||
log "ERROR: Failed to start Sunshine"
|
||||
exit 1
|
||||
export QT_QPA_PLATFORM=wayland
|
||||
export GDK_BACKEND=wayland
|
||||
export CLUTTER_BACKEND=wayland
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
export MOZ_ENABLE_WAYLAND=1
|
||||
export KDEDIRS=/usr
|
||||
export KDE_FULL_SESSION=true
|
||||
export DESKTOP_SESSION=plasma
|
||||
|
||||
unset DISPLAY
|
||||
|
||||
mkdir -p $XDG_RUNTIME_DIR
|
||||
chmod 700 $XDG_RUNTIME_DIR
|
||||
|
||||
log "Launching Plasma: $DESKTOP_BIN"
|
||||
systemd-run --user --scope --quiet \
|
||||
--unit=plasma.scope \
|
||||
--slice=desktop.slice \
|
||||
"$DESKTOP_BIN" >>"$LOGFILE" 2>&1 &
|
||||
plasma_scope_pid=$!
|
||||
log "Plasma started with scope pid $plasma_scope_pid"
|
||||
|
||||
{
|
||||
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 "$plasma_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 "Plasma session ended."
|
||||
exit "$status"
|
||||
@@ -1,21 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/gamescope.log"
|
||||
LOG_FILE="$HOME/.local/logs/session.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOG_FILE"; }
|
||||
|
||||
CONF_FILE="$HOME/.config/gamescope/gamescope.conf"
|
||||
[ -f "$CONF_FILE" ] && source "$CONF_FILE"
|
||||
|
||||
OUTPUT_CONNECTOR=${OUTPUT_CONNECTOR:-HDMI-A-1}
|
||||
FRAMERATE=${FRAMERATE:-60}
|
||||
RESOLUTION=${RESOLUTION:-1920x1080}
|
||||
WIDTH="${RESOLUTION%x*}"
|
||||
HEIGHT="${RESOLUTION#*x}"
|
||||
|
||||
start_gamescope() {
|
||||
log "Starting Gamescope session..."
|
||||
|
||||
CONF_FILE="$HOME/.config/gamescope/gamescope.conf"
|
||||
[ -f "$CONF_FILE" ] && source "$CONF_FILE"
|
||||
|
||||
OUTPUT_CONNECTOR=${OUTPUT_CONNECTOR:-HDMI-A-1}
|
||||
FRAMERATE=${FRAMERATE:-60}
|
||||
RESOLUTION=${RESOLUTION:-1920x1080}
|
||||
WIDTH="${RESOLUTION%x*}"
|
||||
HEIGHT="${RESOLUTION#*x}"
|
||||
|
||||
export __GL_GSYNC_ALLOWED=1
|
||||
export __GL_VRR_ALLOWED=1
|
||||
# export __GL_THREADED_OPTIMIZATIONS=1
|
||||
@@ -38,7 +39,7 @@ start_gamescope() {
|
||||
|
||||
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 "$GAMESCOPE_BIN" ${GAMESCOPE_ARGS} -- "$@" >>"$LOGFILE" 2>&1
|
||||
exec dbus-run-session -- "$GAMESCOPE_BIN" ${GAMESCOPE_ARGS} -- "$@" >>"$LOG_FILE" 2>&1
|
||||
}
|
||||
|
||||
start_kwin() {
|
||||
@@ -49,9 +50,18 @@ start_kwin() {
|
||||
exit 127
|
||||
fi
|
||||
|
||||
KWIN_ARGS="--width $WIDTH --height $HEIGHT"
|
||||
log "Launching KWin: $KWIN_BIN"
|
||||
exec "$KWIN_BIN" ${KWIN_ARGS} "$@" >>"$LOGFILE" 2>&1
|
||||
export XDG_CURRENT_DESKTOP=plasma
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
export XDG_DATA_DIRS=/usr/local/share/:/usr/share/
|
||||
export XDG_CONFIG_DIRS=/usr/local/etc/xdg:/etc/xdg
|
||||
export XDG_CURRENT_DESKTOP=KDE
|
||||
export XDG_RUNTIME_DIR=/run/user/$(id -u)
|
||||
|
||||
# Ensure we don't run nested; width/height/fullscreen are for the windowed backend.
|
||||
unset DISPLAY WAYLAND_DISPLAY
|
||||
KWIN_ARGS="--drm --exit-with-session"
|
||||
log "Launching KWin (DRM): $KWIN_BIN ${KWIN_ARGS} $*"
|
||||
exec dbus-run-session -- "$KWIN_BIN" ${KWIN_ARGS} "$@" >>"$LOG_FILE" 2>&1
|
||||
}
|
||||
|
||||
if [[ -f "$HOME/.desktop-session-plasma" ]]; then
|
||||
@@ -61,4 +71,5 @@ if [[ -f "$HOME/.desktop-session-plasma" ]]; then
|
||||
else
|
||||
log "Gamescope session selected."
|
||||
start_gamescope /usr/local/bin/launch_steam.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -23,5 +23,18 @@ case "$session" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if systemctl --user is-active --quiet steam.scope; then
|
||||
log "Stopping steam.scope"
|
||||
systemctl --user stop steam.scope
|
||||
fi
|
||||
if systemctl --user is-active --quiet plasma.scope; then
|
||||
log "Stopping plasma.scope"
|
||||
systemctl --user stop plasma.scope
|
||||
fi
|
||||
if systemctl --user is-active --quiet sunshine.scope; then
|
||||
log "Stopping sunshine.scope"
|
||||
systemctl --user stop sunshine.scope
|
||||
fi
|
||||
|
||||
log "Restarting graphical session service..."
|
||||
sudo systemctl restart gamescope-session.service
|
||||
Reference in New Issue
Block a user