aboutsummaryrefslogtreecommitdiff
path: root/audio/pianobar/pianobarctl
diff options
context:
space:
mode:
authorPhillip Warner <pc_warner@yahoo.com>2010-12-13 19:30:58 -0200
committerErik Hanson <erik@slackbuilds.org>2010-12-17 07:56:46 -0600
commitfc74e6371c2cc7f80104e05c98d64e9cb2c8316b (patch)
tree52e43c07416ff21f9f4ba17083b5db53a528b192 /audio/pianobar/pianobarctl
parent445b34cf3647da628347b15ea8b1bddbc22866c7 (diff)
audio/pianobar: Updated for version 2010.11.06.
Signed-off-by: Niels Horn <niels.horn@slackbuilds.org>
Diffstat (limited to 'audio/pianobar/pianobarctl')
-rw-r--r--audio/pianobar/pianobarctl71
1 files changed, 71 insertions, 0 deletions
diff --git a/audio/pianobar/pianobarctl b/audio/pianobar/pianobarctl
new file mode 100644
index 0000000000000..ccc99d07a5e75
--- /dev/null
+++ b/audio/pianobar/pianobarctl
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# pianobarctl
+# This script uses a specified named pipe (FIFO) to control pianobar.
+# Written by Phillip Warner
+
+VERSION=0.1
+
+# This is the FIFO that is used to control pianobar
+# It must exist before running pianobar in order for remote control to work
+PIANOBARCTL=~/.config/pianobar/ctl
+
+# Control Functions
+NEXT="n"
+PLAYPAUSE="p"
+LOVE="+"
+BAN="-"
+
+set -e
+
+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 " -n, --next Play Next"
+ echo " -p, --pause Play / Pause"
+ echo " -x, --play Play / Pause"
+ echo " -l, --love Love Song"
+ echo " -b, --ban Ban Song"
+ echo
+ echo "Current pianobar PIDs (euid=$(id -u)):"
+ pgrep -u $(id -u) pianobar$
+}
+
+# Make sure the FIFO exists
+if ! [ -p $PIANOBARCTL ]
+then
+ echo "ERROR. FIFO $PIANOBARCTL does not exist. Try running mkfifo $PIANOBARCTL and then restarting pianobar first. Aborting..."
+ exit 1
+fi
+
+# Make sure pianobar is running and that there is no more than one arg
+if ! (pgrep -u $(id -u) pianobar$ &> /dev/null) || [ $2 ]
+then
+ usage
+elif [ $1 ]
+then
+ case $1 in
+ -h|--help ) usage
+ ;;
+ -n|--next ) echo -n $NEXT > $PIANOBARCTL
+ ;;
+ -p|--pause ) echo -n $PLAYPAUSE > $PIANOBARCTL
+ ;;
+ -x|--play ) echo -n $PLAYPAUSE > $PIANOBARCTL
+ ;;
+ -l|--love ) echo -n $LOVE > $PIANOBARCTL
+ ;;
+ -b|--ban ) echo -n $BAN > $PIANOBARCTL
+ ;;
+ * ) usage
+ ;;
+ esac
+else
+ usage
+fi
+
+exit