add steam gamescope wrapper

This commit is contained in:
Henry Hiles 2026-10-22 23:48:38 -04:00
commit ec8ef7f024
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -1,24 +1,30 @@
{ pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
steam = lib.getExe config.programs.steam.package;
in
{
programs.steam = {
enable = true;
extraCompatPackages = [ pkgs.proton-ge-bin ];
gamescopeSession.enable = true;
};
# Wrap `steam` so everything (including the desktop files steam creates for games) launches inside gamescope
environment.systemPackages = [
(lib.hiPrio (
pkgs.makeDesktopItem {
name = "steam";
desktopName = "Steam";
exec = "steam-gamescope";
icon = "steam";
categories = [
"Network"
"FileTransfer"
"Game"
];
}
pkgs.writeShellScriptBin "steam" ''
# If steam is already running, just hand the args (e.g. steam://rungameid/...) to it
pid=$(cat "$HOME/.steam/steam.pid" 2>/dev/null)
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
exec ${steam} "$@"
fi
exec gamescope --steam -- ${steam} -tenfoot -pipewire-dmabuf "$@"
''
))
];
}