I am running Sway on Fedora 26 and want my laptop to be locked when I close my screen. I changed HandleLidSwitch
to lock
in /etc/systemd/logind.conf
and ran systemctl restart systemd-logind
after that. However, closing the lid does nothing.
The lock program I intend to use is Swaylock and I can manually call it by runnig the command swaylock
in a terminal.
How do I make Systemd call swaylock
when it tries to close the screen (as instructed to do in logind.conf
)?
Best Answer
Target
If the
HandleLidSwitch
is set to sleep, you can create a new systemd service with sleep target, and thus your service will be executed when the sleep is called (lid closed) here is an example with power target.. update that to sleep.Command on lock
This question explain how to run a command when the lock screen is enabled
Screen saver
You can use a bash to watch for screen saver if you want to trigger that when the screen saver is enabled it's explained here