You are not logged in.

#1 2012-08-16 23:22:07

darkfeline
Member
Registered: 2012-02-14
Posts: 94

systemd sleep hook locking X not working

Here's my /usr/lib/systemd/system-sleep/00screensaver-lock:

#!/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 "i3lock" &
        ;;
    post)
        ;;
    *) 
        exit $NA
        ;;
esac

When I do `systemctl suspend`, I can see i3lock starting before the system sleeps, and on resume I see a glimpse of i3lock before it dies and my X session is back.  I've tried `su $USER -c "i3lock"` and `setsid su $USER -c "i3lock"`, but the same happens.  Any ideas?  (The equivalent script with suspend|hibernate instead of pre works fine with pm-utils)

Offline

Board footer

Powered by FluxBB