You are not logged in.
I'm trying to run i3lock upon suspend using this systemd service file:
[Unit]
Description=Screen locker
[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock
[Install]
WantedBy=suspend.target
But the issue I'm having is that the screen lock doesn't actually start, as far as I can tell, until shortly after the computer resumes from suspend. It is such that as the computer resumes, I momentarily see my desktop and can use the mouse/keyboard to do things. This only lasts for less than a second or so before the lock screen appears.
Last edited by Xenograph (2015-01-31 23:40:49)
Offline
Try putting `xhost +si:localuser:root` in your `~/.xinitrc`.
Steven [ web : git ]
GPG: 327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com
Offline
Try putting `xhost +si:localuser:root` in your `~/.xinitrc`.
That didn't help.
Offline
You actually want this run in sleep.target (change to WantedBy=sleep.target). Suspend.target is actually the stuff to do on resume; thus the brief flash of desktop. Clear as mud?
Scott
Offline
You actually want this run in sleep.target (change to WantedBy=sleep.target). Suspend.target is actually the stuff to do on resume; thus the brief flash of desktop. Clear as mud?
Scott
I actually already tried both, thinking that might have been the case. Whether I use sleep.target or suspend.target, I get the same problem
EDIT: Although I still get the brief flash of desktop, it does seem like I can't do any keyboard/mouse input, so that helps a bit with security though not really aesthetics haha.
Last edited by Xenograph (2015-01-31 22:03:34)
Offline
Stebalien wrote:Try putting `xhost +si:localuser:root` in your `~/.xinitrc`.
That didn't help.
Sorry, I totally misread your post. Personally, I hook into loginctl's prepare for sleep signal using a user-service I wrote https://github.com/Stebalien/systemd-user-manager. When run under under a systemd user instance, it will start the user instance's sleep.target and block suspend until the target has started completely. You can use this to pull in i3lock as a user service.
Steven [ web : git ]
GPG: 327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com
Offline
Xenograph wrote:Stebalien wrote:Try putting `xhost +si:localuser:root` in your `~/.xinitrc`.
That didn't help.
Sorry, I totally misread your post. Personally, I hook into loginctl's prepare for sleep signal using a user-service I wrote https://github.com/Stebalien/systemd-user-manager. When run under under a systemd user instance, it will start the user instance's sleep.target and block suspend until the target has started completely. You can use this to pull in i3lock as a user service.
Ah interesting.. I wish there were an easier way to do it though, one that didn't involve hacks for something as simple as starting a lock screen before suspend.
Last edited by Xenograph (2015-01-31 22:44:20)
Offline
This is the complete unit I've been using successfully for quite some time now. Perhaps the 'Before=sleep.target' line will help you.
/etc/systemd/system/suspend@.service
[Unit]
Description=User suspend actions
Before=sleep.target
[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
Environment=HOME=%h
ExecStartPre= -/usr/bin/mysql -e 'stop slave' ; -/usr/local/bin/music.sh stop ; -/usr/bin/pkill -9 unison
ExecStart=-/usr/bin/i3lock -i /tmp/wall.png
[Install]
WantedBy=sleep.target
# systemctl enable suspend@firecat53.service
Last edited by firecat53 (2015-01-31 22:58:51)
Offline
Unfortunately, adding Before=sleep.target didn't help. However, I found a fix, sort of. I added 'sleep 1' under 'ExecStartPost' and now the lock screen successfully starts before the system suspends. Marking as solved.
Last edited by Xenograph (2015-01-31 23:40:39)
Offline