You are not logged in.
I have this in /usr/lib/systemd/systemd-sleep/
#!/bin/sh
#
# 00screensaver-lock: lock workstation on hibernate or suspend
DBUS=$(ps aux | grep 'dbus-launch' | grep -v root)
if [[ ! -z $DBUS ]];then
USER=$(echo $DBUS | awk '{print $1}')
USERHOME=$(getent passwd $USER | cut -d: -f6)
export XAUTHORITY="$USERHOME/.Xauthority"
for x in /tmp/.X11-unix/*; do
DISPLAYNUM=$(echo $x | sed s#/tmp/.X11-unix/X##)
if [[ -f "$XAUTHORITY" ]]; then
export DISPLAY=":$DISPLAYNUM"
fi
done
else
USER=darkfeline
USERHOME=/home/darkfeline
export XAUTHORITY="$USERHOME/.Xauthority"
export DISPLAY=":0"
fi
case "$1" in
pre)
su $USER -c "$USERHOME/bin/myi3lock" &
;;
post)
;;
*)
exit $NA
;;
esac
For some reason, when I resume, I get a quick glimpse of i3lock before it dies. Presumably systemd is killing it or something? I imagine all X lockers have this same problem with systemd. Any solutions?
Last edited by darkfeline (2012-10-04 17:41:06)
Offline
please use code tags.
you may want to use this service file instead:
[Unit]
Description=i3lock
Before=sleep.target
[Service]
User=<user>
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 000000
[Install]
WantedBy=sleep.target
systemctl enable i3lock.service
Offline
Oops, I edited in some code tags.
Thanks for the unit file, it works!
Offline
Find this topic useful. Thank you!
Offline
I'm not sure if anyone is still paying attention to this thread, but after an update, I am getting a similar error:
My resume.service:
[Unit]
Description=User resume actions
Before=sleep.target
[Service]
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 000000
[Install]
WantedBy=sleep.target
I have added in a User line under [Service] to no avail. When trying to enable the service and I return from suspend, systemctl status resume.service reads:
i3lock[14065]: No protocol specified
i3lock[14065]: i3lock: Could not connect to X11, maybe you need to set DISPLAY?
systemd[1]: resume.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Unit resume.service entered failed state.
systemd[1]: resume.service failed.
I've also tried other X-based screen lockers and none work. I am using gdm as the display manager and i3 as the window manager. Could this be an issue with the recent update to X11?
Offline
You probably want to start a new thread. But there's a reason you see horrendous hacks like in the first post - the DISPLAY variable is prone to change, for example when you relogin. You also need XAUTHORITY.
Last edited by Alad (2015-02-17 23:23:17)
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Offline
Thanks, I just posted a new thread:
Offline