Topic: extending the web server functionality

I wrote a few shell scripts that make it possible for users to select which widget is active with the Chumby's web server interface. The first script lists all of the *.swf files found in /mnt/usb/widgets as html links. When a link is clicked, it launches the second script, which kills chumbyflashplayer.x and launches it again with the selected widget.

This is a bit rough around the edges, but it does work. Consider it a proof-of-concept to demonstrate the usefulness of being able to extend the functionality of the Chumby's built-in web server.

The scripts:

/www/cgi-bin/listwidgets:

#!/bin/sh                                                                       

echo "Content-type: text/html"                                                  
echo ""
echo "<html><head>"
echo "<title>Chumby Widget List</title>"
echo "</head></html>"
echo "<body>"
echo "<h2>Widgets</h2>"                                                  

echo "<ul>"
echo "<li><a href=\"startwidget?/usr/widgets/controlpanel.swf\">Default</a></li>"
for f in /mnt/usb/widgets/*.swf
do
        fname=`echo $f | sed 's/^.*\///'`
        echo "<li><a href=\"startwidget?$f\">$fname</a></li>"
done
echo "</ul>"

echo "</body></html>"

/www/cgi-bin/startwidget:

#!/bin/sh                                                                       

echo "Content-type: text/html"                                                  
echo ""
echo "<html><head>"
echo "<title>Starting widget...</title>"
echo "</head></html>"
echo "<body>"

echo "<h3>Lanuching: $QUERY_STRING</h3>"
echo "<a href=\"listwidgets\">Back</a>"

rm -f /tmp/flashplayer_started
killall chumbyflashplayer.x > /dev/null 2>&1
/usr/bin/chumbyflashplayer.x -i $QUERY_STRING > /dev/null 2>&1

To make it work, place the startwidget and listwidgets scripts in /www/cgi-bin, place *.swf files in /mnt/usb/widgets, and point your web browser to:

http://<chumby ip>/cgi-bin/listwidgets

You can also modify /www/cgi-bin/index.html so that it includes a link to the listwidgets script. When I get around to putting an ARM build of Ruby on my thumbdrive I'll probably experiment with more complex CGI stuff. Anybody else out there have any other ideas for new Chumby web server features?

Re: extending the web server functionality

Very nice hack!