You are not logged in.
https://bbs.archlinux.org/viewtopic.php … 7#p2122247
https://wiki.archlinux.org/title/Slock#Lock_on_suspend
This section says to get lock on suspend working you need to do following (create service and enable):
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target
[Service]
User=%i
Environment=DISPLAY=:0
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
Enable the slock@user.service systemd unit for it to take effect for the username user.
However this will make the service crash like:
Sep 21 12:33:07 IdeapadArch xset[1074]: Authorization required, but no authorization protocol specified
Sep 21 12:33:07 IdeapadArch xset[1074]: /usr/bin/xset: unable to open display ":0"
This is because the XAUTHORITY environment variable is not set for non-user systemd. Only after doing
sudo systemctl import-environment XAUTHORITY
does the service work properly. The solution for a static XAUTHORITY location (if you use something like LightDM) is to add an XAUTHORITY environment variable to the service, for example:
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target
[Service]
User=%i
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/%i/.Xauthority
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
If your XAUTHORITY location is not static (like in my case using sddm), I have not found a way to execute 'systemctl import-environment XAUTHORITY' on boot, instead I used xss-lock to attach to system sleep events, see solution https://bbs.archlinux.org/viewtopic.php … 7#p2122247
Last edited by Gonda (2023-09-23 04:51:05)
Offline
Please use the Discussion page on the wiki for discussing corrections to the wiki content.
Offline
Well then add another environment variable to the service file just as DISPLAY is already there.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
OP probably can't - $XAUTHORITY defaults to unset defaults to ~/.Xauthority, except if you're using one of the stupider DMs. Then it's some tmpfile…
Using a user service is also not an option because of one of the stupider strokes of systemd, https://github.com/systemd/systemd/issues/3312
=> wrap slock in some script and import the enviroment there
Offline
... one of the stupider DMs... one of the stupider strokes of systemd
Which is the more applicable aphorism:
- Two wrongs don't make a right
- You can't fix stupid
Either way getting stupid software to do smart things is a waste of time. Just use smarter software.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
"Between systemd and a DisplayManager"
Chances are that the DM is useless.
Offline
OP probably can't - $XAUTHORITY defaults to unset defaults to ~/.Xauthority, except if you're using one of the stupider DMs. Then it's some tmpfile…
Using a user service is also not an option because of one of the stupider strokes of systemd, https://github.com/systemd/systemd/issues/3312=> wrap slock in some script and import the enviroment there
Thank you for your reply. I am using sddm/i3wm and yes, it's some tmpfile, that's why I could just not specify it in the service as ~/.Xauthority. In the end I solved/settled to xss-lock.
Solution:
I copied "/usr/share/doc/xss-lock/transfer-sleep-lock-generic-delay.sh" to a user path. Changed permissions and edited locker value referencing to a script of "/usr/bin/xset dpms force suspend && /usr/bin/slock". Then I added following line in my i3 config:
exec --no-startup-id xss-lock -l *path to script*
as elaborated here: https://www.reddit.com/r/i3wm/comments/ … _of_after/
UPDATE:
I ended up just using LightDM instead of SDDM. No need for the hassle if you don't care about your Display Manager.
Last edited by Gonda (2024-02-17 13:16:35)
Offline
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline