To-Do Rotator for Awesome

Sun, 7 September, 2008

To stay organized, I find two tools indispensable: ToDo.txt for a to-do list and Remind for being reminded of upcoming dates. These two gems leave one problem to the user - how am I notified about to-dos or events? The Remind output is brief enough that I can display it from my .bashrc and see it every time I open a shell.

The ToDo list, however, would clutter this, and I'm left remembering to type 'todo ls' when I'm ready to tackle an item. I have to remember to look at it and want to look at, which I've stopped doing recently.

Luckily, the Awesome window manager made it trivial to write a rotator plug-in which will randomly show me an item from my to-do list or my Remind calendar, consolidating and presenting data from two tools in a way that is harder to ignore. A full screenshot with the rotator in the upper right:

(Yes, it's Sarah Silverman on a toilet. I never said I was a good man.)

And a close-up of the rotator near the clock:

Two scripts are used. fetchItem.sh assembles the inputs and selects a line at random for display. runRotator.sh is the simple daemon that kicks off from the .xinitrc and sends the item into Awesome every 20 seconds.

fetchItem.sh - pick a random line from any text input

#!/bin/bash

TMP_FILE=/home/erik/rotator/data.tmp

#first input source
cat /home/erik/todo/todo.txt \
	| grep -v "^x " | sed 's/^/TODO: /' > $TMP_FILE

#second input source
remind -g /home/erik/.remind | tail -n +2 \
	| sed "/^$/d" | sed 's/^/REMIND: /' >> $TMP_FILE

#choose a line at random

LINE_COUNT=`wc -l "$TMP_FILE" | sed 's/ .*$//'`
SHOW_LINE=$(($RANDOM % $LINE_COUNT))
SHOW_LINE=$(($SHOW_LINE + 1))

cat $TMP_FILE | tail -n $SHOW_LINE | head -n 1

rm $TMP_FILE

You can see that adding new inputs to the rotator is trivial. I just have to append the lines to the temp file. I may patch GnuCash to spit out my net worth, and include that figure in the rotator. Would that be materialistic?

runRotator.sh - the daemon run from .xinitrc

#!/bin/sh

sendItem() {
	echo "0 widget_tell rotator `/home/erik/rotator/fetchItem.sh`" \
		| awesome-client
}

while true; do
	sendItem
	sleep 20
done

Finally, it's necessary to start the daemon when X starts, by launching it as a background process in the .xinitrc when I'm firing up awesome.

/home/erik/rotator/runRotator.sh &
exec awesome

A final note, I'm running Awesome 2.4. Awesome 3.0, I understand, changes the plug-in architecture, but as easy as this was to set up I'm not worried about making the upgrade.

Awesome users: Are there any productivity widgets you've used?

About Me

Erik Mackdanz is a software developer in Austin, Texas, along with everybody else.

Links