lock-screen 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. if [[ $# -eq 0 ]] ; then
  3. echo "lock-screen [ enable | disable | suspend | lock | start ]"
  4. exit
  5. fi
  6. case ${1} in
  7. locker-command)
  8. i3lock -c 536a77 -e -f -n
  9. ;;
  10. locker-command-fork)
  11. i3lock -c 536a77 -e -f
  12. ;;
  13. lock)
  14. ssh-add -D
  15. xidlehook-client --socket ~/.xidlehook.sock \
  16. control --action trigger --timer 0
  17. ;;
  18. daemon)
  19. [ -e ~/.xidlehook.sock ] && rm ~/.xidlehook.sock
  20. echo "Starting xidlehook"
  21. echo "DISPLAY=${DISPLAY}"
  22. xidlehook --socket ~/.xidlehook.sock \
  23. --not-when-fullscreen \
  24. --not-when-audio \
  25. --detect-sleep \
  26. --timer 300 "lock-screen locker-command" ""
  27. ;;
  28. start)
  29. if ! ps aux | grep ' [x]idlehook ' > /dev/null ; then
  30. tmu -e screenlocker screenlocker 'lock-screen daemon'
  31. fi
  32. if ! ps aux | grep '[-]-member Lock' > /dev/null ; then
  33. tmu -e screenlocker dbus-lock 'lock-screen dbus-listen-lock'
  34. fi
  35. if ! ps aux | grep '[-]-member PrepareForSleep' > /dev/null ; then
  36. tmu -e screenlocker dbus-suspend 'lock-screen dbus-listen-suspend'
  37. fi
  38. ;;
  39. dbus-listen-lock)
  40. echo "Listening for org.freedesktop.login1.Session.Lock()"
  41. dbus-listen --system \
  42. --interface org.freedesktop.login1.Session \
  43. --member 'Lock' \
  44. lock-screen lock
  45. ;;
  46. dbus-listen-suspend)
  47. echo "Listening for org.freedesktop.login1.Manager.PrepareForSleep()"
  48. dbus-listen --system \
  49. --interface org.freedesktop.login1.Manager \
  50. --member 'PrepareForSleep' \
  51. lock-screen lock
  52. ;;
  53. disable)
  54. xidlehook-client --socket ~/.xidlehook.sock \
  55. control --action disable --timer 0
  56. ;;
  57. enable)
  58. xidlehook-client --socket ~/.xidlehook.sock \
  59. controll --action enable --timer 0
  60. ;;
  61. suspend)
  62. systemctl suspend
  63. ;;
  64. hibernate)
  65. systemctl hibernate
  66. ;;
  67. suspend-hibernate)
  68. systemctl suspend-hibernate
  69. ;;
  70. *)
  71. echo "lock-screen [ enable | disable | lock | start | suspend | hibernate | suspend-hibernate ]"
  72. esac