aboutsummaryrefslogtreecommitdiff
path: root/audio/herrie/herriectl
blob: 259e777d80eadf2780766af4e973f5285e98ba2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

# herriectl
# This script sends varying signals to all running instances of herrie
# with the same effective uid as the process running this script
# The signal sent is based upon the input argument
# Written by Phillip Warner

VERSION=0.1

# Signales that correspond to functions
SPLAY="SIGRTMIN+1"
SSTOP="SIGRTMIN+2"
SPAUSE="SIGUSR1"
SNEXT="SIGUSR2"
SPREV="SIGRTMIN+3"

usage() {
	echo "$(basename $0) $VERSION - by Phillip Warner"
        echo "Usage:"
        echo "  $0 [OPTION]"
	echo "Only one parameter can be used at a time."
        echo "The script's parameters are:"
        echo "  -h, --help		Help"
	echo "  -b, --next		Play Next"
	echo "  -c, --pause		Pause"
	echo "  -v, --stop		Stop"
	echo "  -x, --play		Play Selected"
	echo "  -z, --previous	Play Previous"
	echo
	echo "Current herrie PIDs (euid=$(id -u)):"
	pgrep -u $(id -u) herrie$
}

# Make sure there is no more than one arg
if [ $2 ]
then
	usage
elif [ $1 ]
then
   case $1 in
      -h|--help ) usage
	;;
      -b|--next ) pkill -$SNEXT -u $(id -u) herrie$
	;;
      -c|--pause ) pkill -$SPAUSE -u $(id -u) herrie$
	;;
      -v|--stop ) pkill -$SSTOP -u $(id -u) herrie$
	;;
      -x|--play ) pkill -$SPLAY -u $(id -u) herrie$
	;;
      -z|--previous ) pkill -$SPREV -u $(id -u) herrie$
	;;
      * ) usage
        ;;
   esac
else
	usage
fi

exit