You are not logged in.
Pages: 1
Hello,
I've recently set up xautolock with i3lock as locker for my desktop. It works fine, but I'd love to have my screen locked when suspending or hibernating my computer.
I've discovered the systemd sleep hooks (https://wiki.archlinux.org/index.php/Po … leep_hooks), but they do not seem to work when enabling service files with the --user option.
Is there a way to use these systemd hooks without setting them up globally?
~/.config/systemd/user/blurlock.service
[Unit]
Description=Blur und lock screen
Before=sleep.target
[Service]
Type=forking
Environment=DISPLAY=:0
ExecStart=/home/stertingen/bin/blurlock
ExecStartPost=/usr/bin/sleep 1
[Install]
WantedBy=sleep.target
~/bin/blurlock
#!/bin/sh
IMGFILE=screen.png
[ -d "$XDG_CACHE_HOME" ] && IMGPATH=$XDG_CACHE_HOME/$IMGFILE || IMGPATH=$HOME/.cache/IMGFILE
sleep 0.1
scrot --silent $IMGFILE --exec "mv $IMGFILE $IMGPATH"
convert $IMGPATH -gaussian-blur 5x5 $IMGPATH
i3lock --image=$IMGPATH
tree ~/.config/systemd/user/
.
├── blurlock.service
└── sleep.target.wants
└── blurlock.service -> /home/stertingen/.config/systemd/user/blurlock.service
Offline
There doesn't seem to be a sleep target in a systemd --user:
$ systemctl --user list-unit-files --all --type target
UNIT FILE STATE
basic.target static
bluetooth.target static
busnames.target static
default.target static
exit.target static
graphical-session-pre.target static
graphical-session.target static
paths.target static
printer.target static
shutdown.target static
smartcard.target static
sockets.target static
sound.target static
timers.target static
I wonder whether the systemd maintainers would consider including it as it seems useful for --user...
Edit: words
Last edited by randomguy (2017-07-05 21:06:22)
Offline
Sorry to revive this, but figured I'd post a useful link in case someone stumbles upon this thread in the future: https://unix.stackexchange.com/question … -hibernate
Essentially, trick is to use dbus in your user session to listen for the event you care about (suspend, screen lock, etc) and start a user version of the target.
Last edited by aiguofer (2018-09-28 04:40:09)
Offline
Can you elaborate more? I do not see how this is using dbus.
Offline
There's a link to a stackoverflow with a link to the code that listens to dbus
Last edited by V1del (2018-11-28 03:00:40)
Offline
Nevermind, I thought the post before me meant a systemd based dbus call. I misread.
Coding it with dbus bindings/implementation in whatever language is obiviously always a solution.
OT: Edit: Thanks for the edit making it more gentile
Last edited by randomguy (2018-11-28 03:12:16)
Offline
Pages: 1