From 36ea2f13f87b9310219790c3cee498201d54f8e0 Mon Sep 17 00:00:00 2001 From: Peter Olson Date: Sat, 27 Jul 2013 17:06:03 -0500 Subject: Added support for EOF and ^D and environment variables to headless_pianobar Closes #382. --- contrib/headless_pianobar | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/headless_pianobar b/contrib/headless_pianobar index b9483c9..20f8a54 100755 --- a/contrib/headless_pianobar +++ b/contrib/headless_pianobar @@ -59,11 +59,11 @@ # This script regularly checks whether or not pianobar is running in the # background in order to detect when it closes. This variable sets how long of # a delay there will be between checks (in seconds). -CHECK_PERIOD="1" +CHECK_PERIOD=${CHECK_PERIOD:-"1"} # This variable will set how many lines of pianobar's output to print when # re-connecting to pianobar. -OUTPUT_LINES="30" +OUTPUT_LINES=${OUTPUT_LINES:-"30"} # Ensure the ctrl fifo exists. if [ ! -p $HOME/.config/pianobar/ctl ] @@ -151,7 +151,10 @@ IFS="" while /bin/true do read -n1 -s INPUT - if [ "$INPUT" == "" ] + if [[ $? == "1" || "$INPUT" == $'\004' ]] + then + quit + elif [ "$INPUT" == "" ] then echo "" > $HOME/.config/pianobar/ctl else -- cgit v1.2.3