herriectl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. # herriectl
  3. # This script sends varying signals to all running instances of herrie
  4. # with the same effective uid as the process running this script
  5. # The signal sent is based upon the input argument
  6. # Written by Phillip Warner
  7. VERSION=0.1
  8. # Signales that correspond to functions
  9. SPLAY="SIGRTMIN+1"
  10. SSTOP="SIGRTMIN+2"
  11. SPAUSE="SIGUSR1"
  12. SNEXT="SIGUSR2"
  13. SPREV="SIGRTMIN+3"
  14. usage() {
  15. echo "$(basename $0) $VERSION - by Phillip Warner"
  16. echo "Usage:"
  17. echo " $0 [OPTION]"
  18. echo "Only one parameter can be used at a time."
  19. echo "The script's parameters are:"
  20. echo " -h, --help Help"
  21. echo " -b, --next Play Next"
  22. echo " -c, --pause Pause"
  23. echo " -v, --stop Stop"
  24. echo " -x, --play Play Selected"
  25. echo " -z, --previous Play Previous"
  26. echo
  27. echo "Current herrie PIDs (euid=$(id -u)):"
  28. pgrep -u $(id -u) herrie$
  29. }
  30. # Make sure there is no more than one arg
  31. if [ $2 ]
  32. then
  33. usage
  34. elif [ $1 ]
  35. then
  36. case $1 in
  37. -h|--help ) usage
  38. ;;
  39. -b|--next ) pkill -$SNEXT -u $(id -u) herrie$
  40. ;;
  41. -c|--pause ) pkill -$SPAUSE -u $(id -u) herrie$
  42. ;;
  43. -v|--stop ) pkill -$SSTOP -u $(id -u) herrie$
  44. ;;
  45. -x|--play ) pkill -$SPLAY -u $(id -u) herrie$
  46. ;;
  47. -z|--previous ) pkill -$SPREV -u $(id -u) herrie$
  48. ;;
  49. * ) usage
  50. ;;
  51. esac
  52. else
  53. usage
  54. fi
  55. exit