Browse Source

Update screen locking management

Samuel W. Flint 1 year ago
parent
commit
384d06921c
1 changed files with 21 additions and 13 deletions
  1. 21 13
      lock-screen

+ 21 - 13
lock-screen

@@ -29,11 +29,28 @@ case ${1} in
         ;;
     start)
         if ! ps aux | grep ' [x]idlehook ' > /dev/null ; then
-            if ! tmux has-session -t 'screenlocker' ; then
-                tmux new-session -s 'screenlocker' -n 'screenlocker' \
-		     -d "$SHELL -c 'lock-screen daemon'"
-            fi
+            tmu -e screenlocker screenlocker 'lock-screen daemon'
         fi
+        if ! ps aux | grep '[-]-member Lock' > /dev/null ; then
+            tmu -e screenlocker dbus-lock 'lock-screen dbus-listen-lock'
+        fi
+        if ! ps aux | grep '[-]-member PrepareForSleep' > /dev/null ; then
+            tmu -e screenlocker dbus-suspend 'lock-screen dbus-listen-suspend'
+        fi
+        ;;
+    dbus-listen-lock)
+        echo "Listening for org.freedesktop.login1.Session.Lock()"
+        dbus-listen --system \
+                    --interface org.freedesktop.login1.Session \
+                    --member 'Lock' \
+                    lock-screen lock
+        ;;
+    dbus-listen-suspend)
+        echo "Listening for org.freedesktop.login1.Manager.PrepareForSleep()"
+        dbus-listen --system \
+                    --interface org.freedesktop.login1.Manager \
+                    --member 'PrepareForSleep' \
+                    lock-screen lock
         ;;
     disable)
         xidlehook-client --socket ~/.xidlehook.sock \
@@ -44,21 +61,12 @@ case ${1} in
                          controll --action enable --timer 0
         ;;
     suspend)
-        ssh-add -D
-        lock-screen lock
-        sleep 1
         systemctl suspend
         ;;
     hibernate)
-        ssh-add -D
-        lock-screen lock
-        sleep 1
         systemctl hibernate
         ;;
     suspend-hibernate)
-        ssh-add -D
-        lock-screen lock
-        sleep 1
         systemctl suspend-hibernate
         ;;
     *)