/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
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.
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.