summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--modules/sunshine.nix58
1 files changed, 47 insertions, 11 deletions
diff --git a/modules/sunshine.nix b/modules/sunshine.nix
index 9384441..b705445 100644
--- a/modules/sunshine.nix
+++ b/modules/sunshine.nix
@@ -46,17 +46,53 @@ in
         PATH = "$(PATH):/run/current-system/sw/bin:/etc/profiles/per-user/${user}/bin:$(HOME)/.local/bin";
       };
 
-      apps = [
-        # the app that moondeck will call when connecting via moonlight
-        {
-          name = "MoonDeckStream";
-          cmd = "${auxiliaryPkgs.moondeck-buddy}/bin/MoonDeckStream";
-          image-path = "${auxiliaryPkgs.moondeck-buddy}/share/icons/hicolor/256x256/apps/moondeckbuddy.png";
-          exclude-global-prep-cmd = "false";
-          elevated = "false";
-        }
-        # + default applications, desktop, low-res desktop, steam big picture
-      ];
+      apps =
+        let
+          command =
+            name: cmd:
+            getExe (
+              pkgs.writeShellApplication {
+                inherit name;
+                runtimeInputs = with pkgs; [
+                  steam
+                  util-linux
+                ];
+                text = "sudo -u ${user} ${cmd}";
+              }
+            );
+        in
+        [
+          # moondeck will call this app when connecting via moonlight, automatically
+          {
+            name = "MoonDeckStream";
+            cmd = "${auxiliaryPkgs.moondeck-buddy}/bin/MoonDeckStream";
+            image-path = "${auxiliaryPkgs.moondeck-buddy}/share/icons/hicolor/256x256/apps/moondeckbuddy.png";
+            exclude-global-prep-cmd = "false";
+            elevated = "false";
+          }
+
+          # other applications, called manually
+          {
+            name = "Desktop";
+            image-path = "desktop.png";
+            # empty commands will always simply open desktop
+          }
+          {
+            name = "Steam";
+            image-path = "steam.png";
+            detached = [ (command "sunshine-open-steam-bp" "steam steam://open/bigpicture") ];
+            prep-cmd = [
+              {
+                do = "";
+                undo = command "sunshine-close-steam-bp" "steam steam://close/bigpicture"; # close up steam
+              }
+            ];
+            # sunshine can't track the steam startup properly, so don't.
+            auto-detach = "true";
+            wait-all = "true";
+            exit-timeout = "5";
+          }
+        ];
     };
   };