Remote controlling via CGI Scripts

=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  or could call existing shell scripts.

Put the scripts in /psp/cgi-bin and access them via the built-in web server: http:///cgi-bin/custom/

=Sound=

Setting the volume
 echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" > /tmp/flashplayer.event echo "" chumbyflashplayer.x -F1 > /dev/null 2>&1 echo "Volume set to ${QUERY_STRING}" 
 * 1) !/bin/sh
 * 2) /psp/cgi-bin/setvol
 * 3) needs volume as parameter between 0 and 100
 * 4) e.g. http:// echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" > /tmp/flashplayer.event chumbyflashplayer.x -F1 
 * 1) !/bin/sh

Unmute with

soma.fm
quick and dirty - just give it the name of your stream (groovesalad|secretagent|lush|digitalis|beatblender|...) as a parameter  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 "" > /tmp/flashplayer.event chumbyflashplayer.x -F1 > /dev/null 2>&1 echo "" echo "" echo "Now playing ${MYFILE}" rm /tmp/${QUERY_STRING}.pls 
 * 1) !/bin/sh

shoutcast stream
Simple example to start a specific shoutcast stream:  echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo "" > /tmp/flashplayer.event chumbyflashplayer.x -F1 > /dev/null 2>&1 echo "" echo "" echo "Now playing KEXP 128k" 
 * 1) !/bin/sh

multiple streams from one file
Straightforward example with querystring argument to choose from a variety of streams (or stop the player). Fill in with streams / stream names as you see fit:  echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" if [ x"${QUERY_STRING}" = xkexp ]; then echo "" > /tmp/flashplayer.event elif [ x"${QUERY_STRING}" = xkuow ]; then echo "<event type=\"UserPlayer\" value=\"play\" comment=\"http://128.208.34.80:8002/\"/>" > /tmp/flashplayer.event elif [ x"${QUERY_STRING}" = xstop ]; then echo "<event type=\"MusicPlayer\" value=\"stop\"/>" > /tmp/flashplayer.event elif [ x"${QUERY_STRING}" = xindiepop ]; then echo "<event type=\"UserPlayer\" value=\"play\" comment=\"http://ice.somafm.com/indiepop\"/>" > /tmp/flashplayer.event elif [ x"${QUERY_STRING}" = xdoomed ]; then echo "<event type=\"UserPlayer\" value=\"play\" comment=\"http://ice.somafm.com/doomed\"/>" > /tmp/flashplayer.event elif [ x"${QUERY_STRING}" = xgroovesalad ]; then echo "<event type=\"UserPlayer\" value=\"play\" comment=\"http://ice.somafm.com/groovesalad\"/>" > /tmp/flashplayer.event else echo "I don't know the $QUERY_STRING stream - try one of: kexp, kuow, indiepop, doomed, groovesalad, or stop" fi chumbyflashplayer.x -F1 > /dev/null 2>&1 echo "" echo "" echo "Now playing ${QUERY_STRING}" </PRE>
 * 1) !/bin/sh

=Dimming the display= Note: This does not seem to work on a chumby8.

can have different values: 0 is normal, 1 is dimmed, 2 is off. According to, 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
 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 </PRE>
 * 1) !/bin/sh

off
echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo 2 > /proc/sys/sense1/dimlevel
 * 1) !/bin/sh

=Change the widget= use  or   as a value 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
 * 1) !/bin/sh

=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). echo "HTTP/1.1 200 ok" echo "Content-type: text/html" echo "" echo "<body style='background-color:666666; color:white'>" echo " " echo " 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> " 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> " echo "mute: <a href='player_setmute?on'>on</a>, <a href='player_setmute?off'>off</a> " echo "play: <a href='player_kexp'>kexp</a>, <a href='player_kuow'>kuow</a>, <a href='player_stop'>stop</a> " echo "display: <a href='display_off'>off</a>, <a href='display_dim'>dimmed</a>, <a href='display_normal'>normal</a>" echo " " echo " " echo ""
 * 1) !/bin/sh