From 211f9e6268939ea5f64969493ec090e4fe3c1f5e Mon Sep 17 00:00:00 2001 From: probono Date: Thu, 26 Dec 2013 11:25:05 +0100 Subject: [PATCH] new file: traits/audio/radio/files/usr/bin/sleeptimer modified: traits/audio/radio/files/www/cgi-bin/radio --- traits/audio/radio/files/usr/bin/sleeptimer | 36 +++++++++++++++++ traits/audio/radio/files/www/cgi-bin/radio | 43 ++++++++++++++------- 2 files changed, 65 insertions(+), 14 deletions(-) create mode 100755 traits/audio/radio/files/usr/bin/sleeptimer diff --git a/traits/audio/radio/files/usr/bin/sleeptimer b/traits/audio/radio/files/usr/bin/sleeptimer new file mode 100755 index 0000000..52c251b --- /dev/null +++ b/traits/audio/radio/files/usr/bin/sleeptimer @@ -0,0 +1,36 @@ +#!/bin/sh + +# Find all PIDs of processes with the same name as myself +PIDS=$(echo $(pidof $(basename $0))) +echo $PIDS + +# Find my PID +MYPID=$(echo $PIDS | cut -d " " -f 2) +echo $MYPID + +# Kill all PIDs of processes with the name name that are not myself +for PID in $PIDS ; do + if [ "$PID" != "$MYPID" ] ; then + echo kill $PID + kill -9 $PID >/dev/null 2>&1 + fi +done + +# Not clean +killall sleep + +# Calculate seconds +MINS=$(uci get radio.sleeptimer || echo 0) +if [ $MINS -gt 100 ] ; then + MINS=0 +fi +NEWMINS=$(($MINS+15)) +uci set radio.sleeptimer=$NEWMINS +NEWSECS=$(($NEWMINS*60)) +speak "Schaltee ab in $NEWMINS Minuten" + +# Sleep for certain time, then switch USB power off +# (if we have set up everything correctly, this stops playback +# and sends shutdown IR signal to external devices) +sleep $NEWSECS ; echo 0 > /sys/class/gpio/gpio8/value + diff --git a/traits/audio/radio/files/www/cgi-bin/radio b/traits/audio/radio/files/www/cgi-bin/radio index a5c69ba..6c5b7cb 100755 --- a/traits/audio/radio/files/www/cgi-bin/radio +++ b/traits/audio/radio/files/www/cgi-bin/radio @@ -51,8 +51,6 @@ echo ' echo "

$(uci get system.@system[0].hostname) ∞

" -echo '
' - # A search field echo '
@@ -72,30 +70,33 @@ echo ' ' # Some buttons -echo " +echo '
-

-" +' + +echo '
' # One button per station +echo '
' STATIONS=$(uci show radio | grep "=station" | cut -d "=" -f 1 | cut -d "." -f 2) COUNTER=0 for STATION in $STATIONS do let COUNTER=COUNTER+1 - echo " "$STATION"" + echo " "$STATION" |" done - -echo '
' - +echo '' # Some debug output # echo "
"
@@ -111,6 +112,10 @@ for SONG in "sunchyme" "orinoco flow" "toto africa" "sunchyme" "wedding rain liz
 "bolero ravel" "Tamee Harrison" ; do
   echo ''$SONG' | '
 done
+
+echo '

' +echo '

Settings

' +echo '

Fork me on Github

' echo "" @@ -177,6 +182,16 @@ if [ "$STRING" == "volume" ] ; then amixer sset $SPEAKER $VOLUME% # This is DANGEROUS, what if some random rubbish is passed in? fi +if [ "$STRING" == "voldown" ] ; then + SPEAKER=$(amixer scontrols | head -n 1 | cut -d "'" -f 2) + amixer set $SPEAKER 7dB- +fi + +if [ "$STRING" == "volup" ] ; then + SPEAKER=$(amixer scontrols | head -n 1 | cut -d "'" -f 2) + amixer set $SPEAKER 7dB+ +fi + if [ "$QUERY_STRING" == "mute" ] ; then SPEAKER=$(amixer scontrols | head -n 1 | cut -d "'" -f 2) amixer sset $SPEAKER '3%'