serhii.net

In the middle of the desert you can say anything you want

08 Jun 2024

Lock before suspend service and command

Arch —Old way with systemd

/etc/systemd/system/user-suspend@.service:

[Unit]
Description=Lock the screen
Before=sleep.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/xlock -usefirst -echokeys -description -modelist swarm,starfish,mandelbrot,polyominoes,fadeplot,matrix,lisa,life3d,life1d,kumppa,grav,flow


[Install]
WantedBy=sleep.target 

To enable1: sudo systemctl enable user-suspend@myusername.service

Arch wiki (Session lock - ArchWiki) omits @myusername which leads to this error:

Failed to enable unit: Destination unit sleep.target is a non-template unit.

Also: xlock (xlockmore) is neat, here’s a list of modes: XlockMore modes

(Also: XScreenSaver versus XLock)

Offtopic but cool: Cool, but obscure X11 tools

Arch and not-arch: New way with xss-lock

Add this to qtile/i3/… autostart:

#xss-lock -- xlock -usefirst -echokeys -modelist qix,lisa & 
# my favourite screensavers
#xss-lock -- xlock -usefirst -echokeys -description -modelist swarm,starfish,mandelbrot,polyominoes,fadeplot,matrix,lisa,life3d,life1d,kumppa,grav,flow &

# xlock is evil and broken 
xss-lock -- xscreensaver-command --lock &

Also

Auto-lock after 300 seconds:

xset s on xset s 300

Also

xlock is insecure, which is why it’s absent from Ubuntu repos, but especially jarring when having an external monitor — on my install, it used to show the lock screen on the external monitor, but show a still image of the desktop and my open programs on the internal one. Damn.

xscreensaver ftw.

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus