Archive for January, 2012

Minimal TODOs for Linux

Saturday, January 7th, 2012

Up until now I’ve just used bits of paper for my TODO system. This has served me quite well, but the problem is that bits of paper are too easily lost or mislaid. So, after reading Minimally Awesome TODOs I wanted to set something similar up for my Ubuntu box. Minimally Awesome TODOs describes a very simple TODO system for the Mac that displays your TODOs on the desktop. With a few tweaks, I got a very similar system working on Linux, which looks like this:

To add a todo you just use a simple terminal command:

$ todo example blog todo

To complete a todo:

$ todone 3

It was pretty easy to port the system from Mac to Linux (I did it on Ubuntu Unity, but it should work for pretty much any Linux distro with a few minor changes) by following the instructions in the post and follow-up comments, but I’ll repeat them here to save others effort. Firstly, create the following shell scripts:

$ cat /usr/local/bin/todo
if [ $# == "0" ]; then cat $TODO; else n=$(($(tail -1 $TODO | cut -d ' ' -f 1) +1)); echo "$n ⇾ $@" >> $TODO; fi

$ cat /usr/local/bin/todone
sed -i -e "/^$*/d" $TODO;

UPDATE: Improvements to these scripts can be found in the comments. Or, even better, try Todo .txt, which has a similarly minimalist interface but some more advanced features. There is also a page on setting it up with conky, similar to what is done below. (I found that I had to rename todo.cfg to config to get Todo .txt to work correctly though). Thanks to Fred for suggesting Todo .txt.

Remember to set them to be executable (chmod +x /usr/local/bin/todo). You then need to set a TODO environment variable to wherever you want to keep your TODO file (i.e. add something like export TODO=~/todo.txt to your .profile). If you want to sync your TODOs over several machines, you could point it to a dropbox folder or similar.

For the next step, you need to install conky, a utility for displaying info (more normally system monitor stuff) on the desktop (you should be able to grab this from your package manager). To get the same set-up as me, use the .conkyrc in this gist – I had to play around with the basic config to get it to display properly in Unity, you may face different problems in other window managers.

Finally, you should set conky to run on startup – in Ubuntu just open Startup Applications and add it to the list. UPDATE: I had a problem with the conky window staying on top of all other windows. To fix this I needed to launch conky from a script which first did sleep 10 to give the window manager time to finish starting up.

I can’t take credit for any of this stuff, all I did was put together a bunch of hints from the internet.

XPathGen Released

Thursday, January 5th, 2012

I’ve just released XPathGen, a simple utility class for generating XPath paths that uniquely identify DOM Nodes in Java.

For example:

Document testDoc = createDocument(
"<a>aa<b attr='test'>b<!-- comment -->c<c/></b>d</a>");

//Grab text node "aa"
Node aa = testDoc.getDocumentElement().getFirstChild();

//Should print "/node()[1]/node()[1]"

I pulled this code out of diffxml and re-licensed it under the Apache licence, so that it can be used more freely.

(This was mainly prompted by this StackOverflow question).

Grab it from github if you’re interested.