# punktfunk headless Steam session — systemd USER unit (Bazzite / SteamOS-like hosts).
#
# DEPRECATED — superseded by the host-managed session (`PUNKTFUNK_GAMESCOPE_SESSION=steam` in
# host.env). The host now LAUNCHES gamescope-session-plus on demand AT THE CLIENT'S mode (so games
# see the client's exact resolution + refresh, dynamically per connection) and relaunches it on a
# mode change. Do NOT enable this fixed-resolution unit alongside the host-managed path — two
# gamescope sessions publish two Video/Source nodes and break node discovery. Kept only for the
# legacy fixed-mode ATTACH setup (`PUNKTFUNK_GAMESCOPE_NODE=auto`); it caps every game at this
# unit's resolution. The PREREQS below still apply to the host-managed path too.
#
# Prereq — free Steam from the local gaming session (so this owns it), on a headless box:
#   sudo loginctl enable-linger $USER         # user services run without a graphical login
#   sudo systemctl set-default multi-user.target   # don't auto-start the local gaming session
#   sudo systemctl isolate multi-user.target       # stop it now (or reboot)
#   sudo cp scripts/99-punktfunk-net.conf /etc/sysctl.d/ && sudo sysctl --system  # big UDP buffers (4K/5K)
#
# Install:
#   mkdir -p ~/.config/systemd/user && cp scripts/punktfunk-steam-session.service ~/.config/systemd/user/
#   # edit SCREEN_WIDTH/HEIGHT below to your client's resolution, then:
#   systemctl --user daemon-reload && systemctl --user enable --now punktfunk-steam-session
#
# Revert to local gaming mode anytime:
#   systemctl --user disable --now punktfunk-steam-session
#   sudo systemctl set-default graphical.target && sudo systemctl isolate graphical.target
[Unit]
Description=punktfunk headless Steam Big Picture session (gamescope-session-plus)
After=pipewire.service pipewire-pulse.service
Wants=pipewire.service

[Service]
# Headless gamescope at the streamed resolution. gamescope-session-plus reads all of these from
# the environment (see /usr/share/gamescope-session-plus/gamescope-session-plus). Set the WIDTH/
# HEIGHT to your client's mode; CUSTOM_REFRESH_RATES advertises selectable rates to Big Picture.
Environment=BACKEND=headless
Environment=SCREEN_WIDTH=5120
Environment=SCREEN_HEIGHT=1440
Environment=CUSTOM_REFRESH_RATES=60,120,240
Environment=STEAM_DISPLAY_REFRESH_LIMITS=60,240
ExecStart=/usr/share/gamescope-session-plus/gamescope-session-plus steam
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target
