feat: Add scripts and systemd services for SteamOS session management and game launching
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/jupiter-biosupdate.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
log "Starting Jupiter BIOS update..."
|
||||
log "Arguments passed: ${@}"
|
||||
echo "Not applicable for this OS"
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/desktop.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
log "Starting Desktop session..."
|
||||
|
||||
DESKTOP_SESSION_BIN="$(command -v startplasma-wayland || true)"
|
||||
if [ -z "$DESKTOP_SESSION_BIN" ]; then
|
||||
log "ERROR: startplasma-wayland not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
log "Launching Desktop: $DESKTOP_SESSION_BIN"
|
||||
exec "$DESKTOP_SESSION_BIN" >>"$LOGFILE" 2>&1 &
|
||||
|
||||
sleep 5
|
||||
systemd-run --user --slice=sunshine.slice --scope sunshine >>"$LOGFILE" 2>&1 || {
|
||||
log "ERROR: Failed to start Sunshine"
|
||||
exit 1
|
||||
} &
|
||||
|
||||
tail -f /dev/null
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/desktop.log"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
DESKTOP_BIN="$(command -v plasmashell || true)"
|
||||
if [ -z "$DESKTOP_BIN" ]; then
|
||||
log "ERROR: plasmashell not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
} &
|
||||
|
||||
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"
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOG_FILE="$HOME/.local/logs/session.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOG_FILE"; }
|
||||
|
||||
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
|
||||
# export __GL_SHADER_DISK_CACHE=1
|
||||
# export __GL_SYNC_TO_VBLANK=0
|
||||
|
||||
GAMESCOPE_BIN="$(command -v gamescope || true)"
|
||||
if [ -z "$GAMESCOPE_BIN" ]; then
|
||||
log "ERROR: gamescope not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
HDR_FLAG=""
|
||||
if [[ "$HDR_ENABLED" == "1" || "$HDR_ENABLED" == "true" || "$HDR_ENABLED" == "yes" ]]; then
|
||||
HDR_FLAG="--hdr-enabled"
|
||||
log "HDR flag added: --hdr-enabled"
|
||||
else
|
||||
log "HDR disabled, no HDR flag added"
|
||||
fi
|
||||
|
||||
env | tee -a "$LOG_FILE"
|
||||
|
||||
# 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() {
|
||||
log "Starting KWin session..."
|
||||
KWIN_BIN="$(command -v kwin_wayland || true)"
|
||||
if [ -z "$KWIN_BIN" ]; then
|
||||
log "ERROR: kwin_wayland not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
export XDG_SEAT=seat0
|
||||
|
||||
if [[ -f "$HOME/.desktop-session-plasma" ]]; then
|
||||
log "Plasma session selected."
|
||||
rm "$HOME/.desktop-session-plasma"
|
||||
start_kwin /usr/local/bin/launch_kde.sh
|
||||
else
|
||||
log "Gamescope session selected."
|
||||
start_gamescope /usr/local/bin/launch_steam.sh
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env bash
|
||||
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
|
||||
# buffer in Wayland. And the color management protocol that is
|
||||
# meant to let this happen is missing the color range...
|
||||
# So just workaround this with an ENV var that Remote Play Together
|
||||
# and Gamescope will use for now.
|
||||
export GAMESCOPE_NV12_COLORSPACE=k_EStreamColorspace_BT601
|
||||
export STEAM_GAMESCOPE_HDR_SUPPORTED=1
|
||||
|
||||
# Workaround older versions of vkd3d-proton setting this
|
||||
# too low (desc.BufferCount), resulting in symptoms that are potentially like
|
||||
# swapchain starvation.
|
||||
export VKD3D_SWAPCHAIN_LATENCY_FRAMES=3
|
||||
|
||||
# Let's try this across the board to see if it breaks anything
|
||||
# Helps performance in HZD, Cyberpunk, at least
|
||||
# Expose 8 physical cores, instead of 4c/8t
|
||||
export WINE_CPU_TOPOLOGY=8:0,1,2,3,4,5,6,7
|
||||
|
||||
# To expose vram info from radv's patch we're including
|
||||
export WINEDLLOVERRIDES=dxgi=n
|
||||
|
||||
# Disable automatic audio device switching in steam, now handled by wireplumber
|
||||
export STEAM_DISABLE_AUDIO_DEVICE_SWITCHING=1
|
||||
|
||||
# Enable support for xwayland isolation per-game in Steam
|
||||
# export STEAM_MULTIPLE_XWAYLANDS=0
|
||||
|
||||
# We have NIS support
|
||||
export STEAM_GAMESCOPE_NIS_SUPPORTED=1
|
||||
|
||||
# Enable tearing controls in steam
|
||||
export STEAM_GAMESCOPE_TEARING_SUPPORTED=1
|
||||
|
||||
# Enable VRR controls in steam
|
||||
export STEAM_GAMESCOPE_VRR_SUPPORTED=1
|
||||
|
||||
# When set to 1, a toggle will show up in the steamui to control whether dynamic refresh rate is applied to the steamui
|
||||
export STEAM_GAMESCOPE_DYNAMIC_REFRESH_IN_STEAM_SUPPORTED=0
|
||||
|
||||
# Don't wait for buffers to idle on the client side before sending them to gamescope
|
||||
export vk_xwayland_wait_ready=false
|
||||
|
||||
# Scaling support
|
||||
export STEAM_GAMESCOPE_FANCY_SCALING_SUPPORT=1
|
||||
|
||||
# Color management support
|
||||
export STEAM_GAMESCOPE_COLOR_MANAGED=1
|
||||
export STEAM_GAMESCOPE_VIRTUAL_WHITE=1
|
||||
|
||||
# Temporary crutch until dummy plane interactions / etc are figured out
|
||||
export GAMESCOPE_DISABLE_ASYNC_FLIPS=1
|
||||
|
||||
export XCURSOR_THEME=steam
|
||||
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
|
||||
log "ERROR: user.max_user_namespaces is 0. Enable it with: sudo sysctl -w user.max_user_namespaces=15000"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v bwrap >/dev/null 2>&1; then
|
||||
bwrap_bin="$(command -v bwrap)"
|
||||
if ! [ -u "$bwrap_bin" ]; then
|
||||
# Not fatal if user namespaces are enabled, but warn for visibility
|
||||
log "WARN: $bwrap_bin is not setuid root. If Steam still fails, run: sudo dnf reinstall bubblewrap && sudo chmod 4755 /usr/bin/bwrap"
|
||||
fi
|
||||
else
|
||||
log "WARN: bubblewrap (bwrap) not found. Steam may fail to start."
|
||||
fi
|
||||
|
||||
if findmnt -no OPTIONS / | grep -qw nosuid; then
|
||||
log "WARN: root filesystem is mounted nosuid. Setuid helpers like bubblewrap will not work."
|
||||
fi
|
||||
|
||||
STEAM_BIN="$(command -v steam || true)"
|
||||
if [ -z "$STEAM_BIN" ]; then
|
||||
log "ERROR: steam not found in PATH"
|
||||
exit 127
|
||||
fi
|
||||
|
||||
log "Updating steam: /opt/steamcmd/steamcmd.sh +quit"
|
||||
/opt/steamcmd/steamcmd.sh +quit >>"$LOGFILE" 2>&1 || {
|
||||
log "ERROR: Steam update failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
log "Launching Steam"
|
||||
STEAM_ARGS=("-steamdeck" "-steamos3" "-steampal" "-gamepadui" "-pipewire-dmabuf")
|
||||
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"
|
||||
|
||||
{
|
||||
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
|
||||
} &
|
||||
|
||||
# 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"
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/steamos-select-branch.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
case "$1" in
|
||||
"-c")
|
||||
log "Current branch requested"
|
||||
echo "stable"
|
||||
exit 0
|
||||
;;
|
||||
"-l")
|
||||
log "Listing available branches"
|
||||
exit 0
|
||||
;;
|
||||
"rel")
|
||||
log "Legacy branch 'rel' requested"
|
||||
exit 0
|
||||
;;
|
||||
"stable" | "rc" | "beta" | "bc" | "preview" | "pc" | "main" | "staging")
|
||||
log "Branch '$1' requested"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "Usage: steamos-select-branch <-c|-l|rel|rc|beta|bc|preview|pc|main>" 1>&2
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/session.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
session="${1:-gamescope}"
|
||||
|
||||
case "$session" in
|
||||
plasma*)
|
||||
log "Plasma session selected."
|
||||
touch "$HOME/.desktop-session-plasma"
|
||||
;;
|
||||
gamescope)
|
||||
log "Gamescope session selected."
|
||||
if [[ -f "$HOME/.desktop-session-plasma" ]]; then
|
||||
rm "$HOME/.desktop-session-plasma"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log "!! Unrecognized session '$session'"
|
||||
exit 1
|
||||
;;
|
||||
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..."
|
||||
systemctl --user restart session.service
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
LOGFILE="$HOME/.local/logs/steamos-update.log"
|
||||
|
||||
log() { echo "[$(date --iso-8601=seconds)] $*" | tee -a "$LOGFILE"; }
|
||||
|
||||
log "Starting SteamOS update..."
|
||||
log "Arguments passed: ${@}"
|
||||
echo "Not applicable for this OS"
|
||||
# TODO: Implement SteamOS update logic for now inform no update available
|
||||
exit 7
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
systemctl --user start steamos.target
|
||||
Reference in New Issue
Block a user