What would this do? And since I use betterlockscreen (i3lock fork) would I actually put exec --no-startup-id xss-lock -- betterlockscreen (plus additional options?)?
xss-lock will fill some of those gaps. by default it will lock on suspend/hibernate, but also recognizes other logind events through dbus. so if you set handlelidswitch=lock in logind, then xss-lock will also handle this. it will handle logind's idle timer too, which honestly is why i avoid it. that is personal preference though (it gives too much control to applications imo).
+1 for xss-lock. Fixed all of my headaches of managing the lockscreen. It even detects when I'm watching a video without some silly mouse-in-corner bull ish
I just had to dig into this very same area. As u/LinuxPoodle mentioned, xautolock itself isn't going to detect when your lid is closed.
What I ended up doing was creating a systemd service tied to sleep.target which executes i3lock with the non-blocking flag (-n) right before going to sleep/suspend. This works entirely separate from the xautolock timer, but because nothing happens when your laptop is in suspend state, the systemd service and xautolock shouldn't interfere.
Save this as something like /etc/systemd/system/lock-on-suspend.service, then enable it using sudo systemctl enable lock-on-suspend.
Hopefully this helps. And hopefully I won't get downvoted into oblivion which seems to be what happens whenever I provide a solution in this sub, haha.
Edit: In the service, make sure to change [USERNAME] with your actual username!
xautolock is just a timer with some extras (corner mouse pointer toggle, and notify before lock, very cool if you just seem to be away because reading something on screen without scrolling).
it does not do "laptop lid" as far as I know of, I think for that you have to look to systemd login.conf handlelidswitch or whatever.
so what you need there is any script that reacts to "laptop lid" and tells xautolock to lock or just directly runs the locker itself - in which case you may end up with two locker instances, one spawned by the lid, and one by the timeout, but you can work around that by using a locker that checks it's not already running
I don't know why i can't get suspend on lid close with the logind config solution on i3. But, strangely, running xautolock -locker "systemctl suspend".
xautolock seems to detect lid close on my system, any insight about it ?
11 comments
Try add this in i3 config:
exec --no-startup-id xss-lock -- i3lock
What would this do? And since I use
betterlockscreen(i3lockfork) would I actually putexec --no-startup-id xss-lock -- betterlockscreen(plus additional options?)?not having a DM/DE leaves some gaps with logind.
xss-lock will fill some of those gaps. by default it will lock on suspend/hibernate, but also recognizes other logind events through dbus. so if you set handlelidswitch=lock in logind, then xss-lock will also handle this. it will handle logind's idle timer too, which honestly is why i avoid it. that is personal preference though (it gives too much control to applications imo).
+1 for xss-lock. Fixed all of my headaches of managing the lockscreen. It even detects when I'm watching a video without some silly mouse-in-corner bull ish
I just had to dig into this very same area. As u/LinuxPoodle mentioned,
xautolockitself isn't going to detect when your lid is closed.What I ended up doing was creating a systemd service tied to
sleep.targetwhich executes i3lock with the non-blocking flag (-n) right before going to sleep/suspend. This works entirely separate from the xautolock timer, but because nothing happens when your laptop is in suspend state, the systemd service and xautolock shouldn't interfere.This is my systemd service:
Save this as something like
/etc/systemd/system/lock-on-suspend.service, then enable it usingsudo systemctl enable lock-on-suspend.Hopefully this helps. And hopefully I won't get downvoted into oblivion which seems to be what happens whenever I provide a solution in this sub, haha.
Edit: In the service, make sure to change
[USERNAME]with your actual username!Enabled, rebooted, no visible effect. Screen (still) goes black when shutting lid but doesn't lock.
Try checking your journal to see if there are errors:
journalctl -u lock-on-suspend. ("lock-on-suspend" or whatever you named the service.)Also, which i3lock AUR package are you using?
May even want to change laptop lid lock from 30 seconds to 0, so it locks instantly.
sudo sed -i -e 's/#HoldoffTimeoutSec=30s/HoldoffTimeoutSec=0s/g' /etc/systemd/logind.confxautolock is just a timer with some extras (corner mouse pointer toggle, and notify before lock, very cool if you just seem to be away because reading something on screen without scrolling).
it does not do "laptop lid" as far as I know of, I think for that you have to look to systemd login.conf handlelidswitch or whatever.
so what you need there is any script that reacts to "laptop lid" and tells xautolock to lock or just directly runs the locker itself - in which case you may end up with two locker instances, one spawned by the lid, and one by the timeout, but you can work around that by using a locker that checks it's not already running
I don't know why i can't get suspend on lid close with the logind config solution on i3. But, strangely, running xautolock -locker "systemctl suspend".
xautolock seems to detect lid close on my system, any insight about it ?