random script dump
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
1.1 KiB

  1. #!/usr/bin/env zsh
  2. pidfile=${XDG_RUNTIME_DIR-/run/user/$UID}/xscreensaver-companion.pid
  3. trap "rm -f $pidfile" INT KILL
  4. function check_start
  5. {
  6. # check if the service is running and, if not, start it in the background
  7. # and detach
  8. if pgrep -u $USER $1 >/dev/null; then
  9. return 0
  10. else
  11. $* &>/dev/null </dev/null & disown
  12. fi
  13. }
  14. function init_pidfile
  15. {
  16. local pid
  17. if read pid < $pidfile; then
  18. if kill -0 $pid; then
  19. echo 'I am already running!' >&2
  20. exit 1
  21. else
  22. echo 'Remove stale lock file.' >&2
  23. rm $pidfile
  24. fi
  25. fi
  26. echo $$ > $pidfile
  27. }
  28. function parse_actions
  29. {
  30. while read action _; do
  31. case $action in
  32. (LOCK|BLANK)
  33. setxkbmap us -option
  34. notify-send DUNST_COMMAND_PAUSE
  35. ;;
  36. (UNBLANK)
  37. check_start gxkb
  38. $HOME/git/mine/vscripts/mykblayouts
  39. $HOME/.local/bin/touchpad-config
  40. notify-send DUNST_COMMAND_RESUME
  41. ;;
  42. esac
  43. done
  44. }
  45. init_pidfile
  46. xscreensaver-command -watch | parse_actions