You are not logged in.
Pages: 1
I was trying to create a service that would lock my screen when I suspend my laptop and I was partially successful. In the end I ended up with two issues.
First of all this is the service file:
[Unit]
Description=i3lock
Before=sleep.target
[Service]
User=mk
Environment=DISPLAY=:0
ExecStart=/home/mk/bin/lock_screen.sh
[Install]
WantedBy=sleep.targetThis works quite well, except for the fact that I have to run it as a system service:
sudo systemctl enable lock_screen.serviceIf I try to run it as a user service (I remove the User=mk part from the service file and put it in .config/systemd/user)
systemctl --user enable lock_screen.serviceIt simply does not work, when I run systemctl status it just returns:
● lock_screen.service - i3lock
Loaded: loaded (/home/mk/.config/systemd/user/lock_screen.service; enabled; vendor preset: enabled)
Active: inactive (dead)It seems as if it is simply never run by systemd.
My second issue with this lockscreen is that it always runs on display :0, this can be somewhat problematic, what I would prefer is that it ran on the current display, if it has an x server and otherwise let it run physlock instead, however I can't seem to find a way to do this.
Edit:
I Partially solved the second issue, by checking for the display environment variable in my screen lock script, however this will not work when it is started by systemd, since systemd doesn't know my current display.
my lockscreen start script:
#!/bin/sh
if [ -z $DISPLAY ]
then
physlock -s
else
physlock -l
i3lock --nofork
physlock -L
fiLast edited by Meikk99 (2019-10-10 17:04:37)
Offline
Pages: 1