-
Notifications
You must be signed in to change notification settings - Fork 0
/
pithos-control
executable file
·49 lines (40 loc) · 1012 Bytes
/
pithos-control
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
#!/bin/bash
#
# Control pithos from multimedia keys in XFCE
#
# Set usage output
USAGE="[-h |--help] [-p | --pause] [-s | --skip]"
LONGUSAGE="\t-h, --help\n\t\tPrint this help message
\t-p, --pause\n\t\t(Un)pause
\t-s, --skip\n\t\tSkip this song"
# Standard functions
source ${SCRIPTS}/functions.sh
# Script name
ME=$(basename $0)
# Parse arguments
ARGS=`getopt -o hps --long help,pause,skip -n "${ME}" -- "$@"`
if [ $? != 0 ] ; then
usage
fi
eval set -- "$ARGS"
while true ; do
case "$1" in
-h|--help) usage; shift ;;
-p|--pause) PAUSE="yes"; shift ;;
-s|--skip) SKIP="yes"; shift ;;
--) shift ; break ;;
* ) usage "Invalid argument $1";;
esac
done
if [ -n "${PAUSE}" -a -n "${SKIP}" ]; then
usage "Can't skip and pause at the same time"
fi
if [ -n "${PAUSE}" ]; then
CMD="PlayPause"
elif [ -n "${SKIP}" ]; then
CMD="SkipSong"
else
usage "Must skip or pause"
fi
echo "${CMD}"
dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.${CMD}