Remote controlling via CGI Scripts
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
General interface
Once some of the above scripts are in place, you can create a file named "index" in the same directory, make it executable, and put these contents into that file and you'll have a small remote control for your chumby to control from a phone, laptop, or other device on your network. In this example, I have three chumbies, each with copies of these scripts in cgi-bin. The link at the top lets me change between the three. I also have a couple links to start some specific streaming radio stations (player_kexp and player_kuow).
#!/bin/sh echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo "<body style='background-color:666666; color:white'>" echo "<center>" echo "<h1>Chumby <a href='http://192.168.1.122/cgi-bin/custom/index'>Classic</a>, <a href='http://192.168.1.123/cgi-bin/custom/index'>Black8</a>, <a href='http://192.168.1.124/cgi-bin/custom/index'>Red8</a></h1>" echo "volume: <a href='player_setvol?20'>20</a>, <a href='player_setvol?40'>40</a>, <a href='player_setvol?60'>60</a>, <a href='player_setvol?80'>80</a>, <a href='player_setvol?100'>100</a><br>" echo "mute: <a href='player_setmute?on'>on</a>, <a href='player_setmute?off'>off</a><br>" echo "play: <a href='player_kexp'>kexp</a>, <a href='player_kuow'>kuow</a>, <a href='player_stop'>stop</a><br>" echo "display: <a href='display_off'>off</a>, <a href='display_dim'>dimmed</a>, <a href='display_normal'>normal</a>" echo "</center>" echo "</body>" echo ""