Hook graphical widgets to shell scripts and you have a powerful but under-utilized class of applications. Systems programmers are typically writing code that does not need user interaction. Software developers are typically writing larger-scale programs in languages with rich widget libraries. But the domain in between does have some important uses, for instance small-scale programs that need input from non-technical operators, or need to alert them as tasks succeed (or fail).
I was reminded of this the other day when looking for a really simple Twitter client, just something I could click from the desktop or taskbar, input a string of text and be done. The one I found was a single-line shell script that used kdialog. I added a line to catch errors. Here is the complete script.
#!/bin/bash
curl -u username:password -s -F status="`kdialog --inputbox 'what are you doing right now?'`" http://twitter.com/statuses/update.xml http://twitter.com/account/end_session
if [ $? != 0 ]; then kdialog --error 'Twitter could not be updated'; fi
The next day I happened to read about a Python module that provides similar functionality for Mac OS X; it's called EasyDialogs. So I made a Mac version (my first real Python program). Here it is.
#!/usr/bin/pythonw
import EasyDialogs
import os
ret = os.system('curl -u username:password -s -F status="' + EasyDialogs.AskString('What are you doing right now?') + '" http://twitter.com/statuses/update.xml http://twitter.com/account/end_session')
if ret:
EasyDialogs.Message('Twitter could not be updated.')
Either can be made executable and linked from the dock/taskbar for quick launch. Check out the tutorials for kdialog or EasyDialog for a better idea of what the possibilities are (complete with many graphical examples) using the standard widgets such as file choosers, checkboxes, etc.