-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sunshine: hack steam big picture mode
- Loading branch information
1 parent
79843c8
commit f76594d
Showing
1 changed file
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,81 @@ | ||
{pkgs, ...}: { | ||
{pkgs, ...}: let | ||
steam-run-url = pkgs.writeShellApplication { | ||
name = "steam-run-url"; | ||
|
||
runtimeInputs = [ | ||
pkgs.coreutils # For `id` commands | ||
]; | ||
|
||
text = '' | ||
echo "$1" > "/run/user/$(id --user)/steam-run-url.fifo" | ||
''; | ||
}; | ||
in { | ||
environment.systemPackages = with pkgs; [ | ||
moonlight-qt | ||
steam-run-url | ||
]; | ||
|
||
services = { | ||
sunshine = { | ||
enable = true; | ||
|
||
applications = { | ||
apps = [ | ||
{ | ||
auto-detach = "true"; | ||
|
||
detached = [ | ||
"${steam-run-url}/bin/steam-run-url steam://open/bigpicture" | ||
]; | ||
|
||
image-path = "steam.png"; | ||
name = "Steam - Big Picture Mode"; | ||
output = "steam.txt"; | ||
} | ||
]; | ||
}; | ||
|
||
autoStart = true; | ||
capSysAdmin = true; | ||
openFirewall = true; | ||
autoStart = true; | ||
}; | ||
|
||
udev.extraRules = '' | ||
KERNEL=="uinput", GROUP="input", MODE="0660" OPTIONS+="static_node=uinput" | ||
''; | ||
}; | ||
|
||
systemd.user.services = { | ||
steam-run-url-service = { | ||
enable = true; | ||
after = ["graphical-session.target"]; | ||
description = "Listen and starts steam games by id."; | ||
partOf = ["graphical-session.target"]; | ||
path = [pkgs.steam]; | ||
|
||
script = toString (pkgs.writers.writePython3 "steam-run-url-service" {} '' | ||
import os | ||
from pathlib import Path | ||
import subprocess | ||
pipe_path = Path(f'/run/user/{os.getuid()}/steam-run-url.fifo') | ||
try: | ||
pipe_path.parent.mkdir(parents=True, exist_ok=True) | ||
pipe_path.unlink(missing_ok=True) | ||
os.mkfifo(pipe_path, 0o600) | ||
while True: | ||
with pipe_path.open(encoding='utf-8') as pipe: | ||
subprocess.Popen(['steam', pipe.read().strip()]) | ||
finally: | ||
pipe_path.unlink(missing_ok=True) | ||
''); | ||
|
||
serviceConfig.Restart = "on-failure"; | ||
wantedBy = ["graphical-session.target"]; | ||
wants = ["graphical-session.target"]; | ||
}; | ||
|
||
sunshine.path = [steam-run-url]; | ||
}; | ||
} |