lock-screen 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. xidlehook --socket ~/.xidlehook.sock \
  22. --not-when-fullscreen \
  23. --not-when-audio \
  24. --detect-sleep \
  25. --timer 300 "lock-screen locker-command" ""
  26. ;;
  27. start)
  28. if ! ps aux | grep ' [x]idlehook ' > /dev/null ; then
  29. if ! tmux has-session -t 'screenlocker' ; then
  30. tmux new-session -s 'screenlocker' -n 'screenlocker' -d "$SHELL -c 'lock-screen daemon'"
  31. fi
  32. fi
  33. ;;
  34. disable)
  35. xidlehook-client --socket ~/.xidlehook.sock \
  36. control --action disable --timer 0
  37. ;;
  38. enable)
  39. xidlehook-client --socket ~/.xidlehook.sock \
  40. controll --action enable --timer 0
  41. ;;
  42. suspend)
  43. ssh-add -D
  44. lock-screen lock
  45. sleep 1
  46. systemctl suspend
  47. ;;
  48. hibernate)
  49. ssh-add -D
  50. lock-screen lock
  51. sleep 1
  52. systemctl hibernate
  53. ;;
  54. suspend-hibernate)
  55. ssh-add -D
  56. lock-screen lock
  57. sleep 1
  58. systemctl suspend-hibernate
  59. ;;
  60. *)
  61. echo "lock-screen [ enable | disable | lock | start | suspend | hibernate | suspend-hibernate ]"
  62. esac