systemd service to run apps headlessly in gamemode

I am trying to run some apps headlessly in steam game mode (pcloud, openrgb, discord, and jamesdsp) all these apps except openrgb should ONLY be run headlessly when in steam game mode, otherwise they start up as normal by kde's autostart. so far this is what I have
cat .config/systemd/user/openrgb.service
[Unit]
Description=OpenRGB control

[Service]
Type=simple
ExecStart=/home/zany130/AppImages/openrgb_8682f8.appimage --profile MyRGB --server
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4

[Install]
WantedBy=default.target
╰─❯ cat .config/systemd/user/gamescopeApps.service
[Unit]
Description=headless apps to run in gamescope session

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
╰─❯ cat Scripts/startGamescopeAppsBazzite.sh
#!/bin/bash
flatpak kill me.timschneeberger.jdsp4linux
killall pcloud
sleep 10s
/usr/bin/xvfb-run flatpak run me.timschneeberger.jdsp4linux &
/usr/bin/xvfb-run flatpak run com.discordapp.Discord &
/usr/bin/xvfb-run /home/zany130/AppImages/pcloud_082454.appimage &
cat .config/systemd/user/openrgb.service
[Unit]
Description=OpenRGB control

[Service]
Type=simple
ExecStart=/home/zany130/AppImages/openrgb_8682f8.appimage --profile MyRGB --server
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4

[Install]
WantedBy=default.target
╰─❯ cat .config/systemd/user/gamescopeApps.service
[Unit]
Description=headless apps to run in gamescope session

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
╰─❯ cat Scripts/startGamescopeAppsBazzite.sh
#!/bin/bash
flatpak kill me.timschneeberger.jdsp4linux
killall pcloud
sleep 10s
/usr/bin/xvfb-run flatpak run me.timschneeberger.jdsp4linux &
/usr/bin/xvfb-run flatpak run com.discordapp.Discord &
/usr/bin/xvfb-run /home/zany130/AppImages/pcloud_082454.appimage &
and then I just modifed the Return.desktop file on the desktop to
cat Desktop/Return.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Return to Gaming Mode
Exec=systemctl start return-to-gamemode.service & systemctl --user start & openrgb.service systemctl --user start gamescopeApps.service
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
cat Desktop/Return.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Return to Gaming Mode
Exec=systemctl start return-to-gamemode.service & systemctl --user start & openrgb.service systemctl --user start gamescopeApps.service
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
so my services are started when I switch to steam game mode but gamescopeApps.service persits into the kde session as well which I don't want (since kde is starting these same apps with its autostart)
Solution:
so went back to my original idea with a few changes first I actually had a typo with & in the Return.desktop file so what I did was add a Requires=openrgb.service and After=openrgb.service to the gamsecopeapps.service so I don't have to chain so many &...
Jump to solution
2 Replies
zany130
zany1302mo ago
in openrgb case its fine that service starts in kde because its just running the openrgb server not the gui. so I can still autostart the gui with kde autostart but the others are running with xvfb-run and I don't want that when i am on KDE according to chat gpt this service would do exatcly what I want
cat .config/systemd/user/gamescopeApps.service
[Unit]
Description=headless apps to run in gamescope session
PartOf=gamescope-session-plus@.service

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh
Restart=on-failure
RestartSec=1
cat .config/systemd/user/gamescopeApps.service
[Unit]
Description=headless apps to run in gamescope session
PartOf=gamescope-session-plus@.service

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh
Restart=on-failure
RestartSec=1
and then I just remove the modifcations I did to the desktop file. lets see if its right.... Edit: nope didn't have high hopes
Solution
zany130
zany1302mo ago
so went back to my original idea with a few changes first I actually had a typo with & in the Return.desktop file so what I did was add a Requires=openrgb.service and After=openrgb.service to the gamsecopeapps.service so I don't have to chain so many & the finally result looks like this .config/systemd/user/openrgb.service
[Unit]
Description=OpenRGB control

[Service]
Type=simple
ExecStart=/home/zany130/AppImages/openrgb_8682f8.appimage --profile MyRGB --server
Restart=on-failure
RestartSec=1

[Install]
WantedBy=default.target
[Unit]
Description=OpenRGB control

[Service]
Type=simple
ExecStart=/home/zany130/AppImages/openrgb_8682f8.appimage --profile MyRGB --server
Restart=on-failure
RestartSec=1

[Install]
WantedBy=default.target
cat .config/systemd/user/gamescopeApps.service

[Unit]
Description=headless apps to run in gamescope session
Requires=openrgb.service
After=openrgb.service

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh
Restart=on-failure
RestartSec=1

[Unit]
Description=headless apps to run in gamescope session
Requires=openrgb.service
After=openrgb.service

[Service]
Type=forking
ExecStart=/home/zany130/Scripts/startGamescopeAppsBazzite.sh
Restart=on-failure
RestartSec=1
cat Desktop/Return.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Return to Gaming Mode
Exec=systemctl start return-to-gamemode.service & systemctl --user start gamescopeApps.service
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Return to Gaming Mode
Exec=systemctl start return-to-gamemode.service & systemctl --user start gamescopeApps.service
Icon=steamdeck-gaming-return
Terminal=false
Type=Application
StartupNotify=false
cat Scripts/startGamescopeAppsBazzite.sh
#!/bin/bash
flatpak kill me.timschneeberger.jdsp4linux
killall pcloud
sleep 10s
/usr/bin/xvfb-run flatpak run me.timschneeberger.jdsp4linux --watch &
/usr/bin/xvfb-run flatpak run com.discordapp.Discord &
/usr/bin/xvfb-run /home/zany130/AppImages/pcloud_082454.appimage &
#!/bin/bash
flatpak kill me.timschneeberger.jdsp4linux
killall pcloud
sleep 10s
/usr/bin/xvfb-run flatpak run me.timschneeberger.jdsp4linux --watch &
/usr/bin/xvfb-run flatpak run com.discordapp.Discord &
/usr/bin/xvfb-run /home/zany130/AppImages/pcloud_082454.appimage &
the reason why it was autostarting in plasma for me before is because I had the gamescopeApps.service previously enabled with the default.target all I had to do was systemctl --user disable gamescopeApps.service and it was fixed no more auto starting in plasma now jamesdsp, pcloud, discord, and openrgb are all started headlessy when ever I switch to gamemode from the desktop and I have my system setup to auto start to plasma instead of game mode with ujust _toggle-autologin so I will always run the desktop file anyway to go into gamemode. no need to complicate things and make it "achtually" start with gamemode
Want results from more Discord servers?
Add your server