Skip to content

Instantly share code, notes, and snippets.

@hammerill
Last active April 19, 2025 10:28
Show Gist options
  • Save hammerill/da701e76b73cc7c7414559252e6f1f66 to your computer and use it in GitHub Desktop.
Save hammerill/da701e76b73cc7c7414559252e6f1f66 to your computer and use it in GitHub Desktop.

Sunshine Lock Systemd Entry

/etc/systemd/user/sunshine-lock.service:

[Unit]
Description=Lock Screen When Sunshine Loaded
After=sunshine.service

[Service]
ExecStart=/usr/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock

[Install]
WantedBy=graphical-session.target

Important

This will work if you're using a DE respecting Freedesktop Dbus conventions (such as KDE).

If you're using some other DE/WM, you must find another command to lock your screen.

Then do this:

systemctl enable --user sunshine-lock.service

Why?

Running under Linux, Sunshine, an open source game stream server you can access here, requires a graphical session with a user being logged in.

In the situation when this has to be performed without human intervention after a reboot, the session must log in automatically. That leaves the PC accessible with no password asked just after booting each time.

To prevent that, this Systemd entry will lock the screen immediately when Sunshine server is loaded. This might leave a fraction of a second when you can do something without a password, but still it's safer than just a PC open wide.

Bonus

If kwallet becomes annoying with the password being asked each boot after autologin was enabled, install KWalletManager and set kwallet password to an empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment