Difference between revisions of "Remote controlling via CGI Scripts"
(Remote Control your Chumby via cgi scripts and the built-in webserver) |
m (corrected /tmp/flashplayer.event file name) |
||
Line 15: | Line 15: | ||
echo "HTTP/1.1 200 ok" | echo "HTTP/1.1 200 ok" | ||
echo "Content-type: text/html" | echo "Content-type: text/html" | ||
− | echo "<event type=\"MusicPlayer\" value=\"setVolume\" comment=\"${QUERY_STRING}\"/>" > /tmp/flashplayer. | + | echo "<event type=\"MusicPlayer\" value=\"setVolume\" comment=\"${QUERY_STRING}\"/>" > /tmp/flashplayer.event |
echo "" | echo "" | ||
chumbyflashplayer.x -F1 > /dev/null 2>&1 | chumbyflashplayer.x -F1 > /dev/null 2>&1 |
Revision as of 09:04, 27 July 2011
Contents
Basic Concept
I love my chumby, especially to listen to internet radio streams. But I hate to manipulate the device "by hand" to change a station or turn down the volume. Here are some simple cgi scripts to remote control your chumby. Basically, we're manipulating the control panel as described here via some cgi-scripts: Built-in webserver. Alternatively, we can manipulate /proc
or could call existing shell scripts.
Put the scripts in /psp/cgi-bin and access them via the built-in web server:
http://<ip.of.your.chumby>/cgi-bin/custom/<name.of.your.script>
Sound
Setting the volume
#!/bin/sh # /psp/cgi-bin/setvol # needs volume as parameter between 0 and 100 # e.g. http://<ip.of.you.chumby/cgi-bin/custom/setvol?30 # echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "<event type=\"MusicPlayer\" value=\"setVolume\" comment=\"${QUERY_STRING}\"/>" > /tmp/flashplayer.event echo "" chumbyflashplayer.x -F1 > /dev/null 2>&1 echo "Volume set to ${QUERY_STRING}"
NB: Make sure you escape any quotation marks when echoing them in your script.
Muting
#!/bin/sh echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "<event type=\"MusicPlayer\" value=\"setMute\" comment=\"on\"/>" > /tmp/flashplayer.event chumbyflashplayer.x -F1
Unmute with comment="off"
soma.fm
quick and dirty - just give it the name of your stream (groovesalad|secretagent|lush|digitalis|beatblender|...) as a parameter
#!/bin/sh echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" wget -c http://somafm.com/startstream=fw/${QUERY_STRING}.pls -O /tmp/${QUERY_STRING}.pls MYFILE=`grep File1= /tmp/${QUERY_STRING}.pls | cut -d "=" -f2` echo "<event type=\"UserPlayer\" value=\"play\" comment=\"${MYFILE}\"/>" > /tmp/flashplayer.event chumbyflashplayer.x -F1 > /dev/null 2>&1 echo "" echo "" echo "Now playing ${MYFILE}" rm /tmp/${QUERY_STRING}.pls
Dimming the display
/proc/sys/sense1/dimlevel
can have different values: 0 is normal, 1 is dimmed, 2 is off. According to [1], the display can't go from off to dimmed, so when going to the dimmed level, we just always switch to the normal level first and wait for a second.
dimmed
#!/bin/sh echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo 0 > /proc/sys/sense1/dimlevel sleep 1 echo 1 > /proc/sys/sense1/dimlevel
off
#!/bin/sh echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo 2 > /proc/sys/sense1/dimlevel
Change the widget
use nextWidget
or prevWidget
as a value
#!/bin/sh echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo "<event type=\"WidgetPlayer\" value=\"nextWidget\" comment=\"\"/>" > /tmp/flashplayer.event chumbyflashplayer.x -F1 > /dev/null 2>&1