lock-screen 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. if ! tmux has-session -t 'screenlocker' ; then
  31. tmux new-session -s 'screenlocker' -n 'screenlocker' \
  32. -d "$SHELL -c 'lock-screen daemon'"
  33. fi
  34. fi
  35. ;;
  36. disable)
  37. xidlehook-client --socket ~/.xidlehook.sock \
  38. control --action disable --timer 0
  39. ;;
  40. enable)
  41. xidlehook-client --socket ~/.xidlehook.sock \
  42. controll --action enable --timer 0
  43. ;;
  44. suspend)
  45. ssh-add -D
  46. lock-screen lock
  47. sleep 1
  48. systemctl suspend
  49. ;;
  50. hibernate)
  51. ssh-add -D
  52. lock-screen lock
  53. sleep 1
  54. systemctl hibernate
  55. ;;
  56. suspend-hibernate)
  57. ssh-add -D
  58. lock-screen lock
  59. sleep 1
  60. systemctl suspend-hibernate
  61. ;;
  62. *)
  63. echo "lock-screen [ enable | disable | lock | start | suspend | hibernate | suspend-hibernate ]"
  64. esac