Blog RSS

The thought-stream of Tom Medhurst

Archive

May
3rd
Sun
permalink

Using dmenu to access your delicious.com account

I really like dmenu. It’s like Quicksilver or GNOME DO, but much smaller, faster, and easier to extend!

The common dmenu command to quickly run a program from your path would be something like:

dmenu_path | dmenu

The dmenu_path command quickly fetches all programs from your $PATH and sends the list (newline-separated) into dmenu for user-selection.

Because of the great de-coupled design of dmenu, we can easily hack it to do something slightly cooler!

So what I thought I would try is to grab a list of all my delicious.com tags and display them in dmenu. When I select a tag and hit the return key; I want Firefox to launch and show me all my links associated with that tag…

First step is to grab the list of tags, this can be done with curl, using the command:

curl -u MY_USERNAME:MY_PASSWORD https://api.del.icio.us/v1/tags/get

This should then return the list of tags, however it returns them in XML format. :S
To grab only the tags, I thought I would pipe the xml into awk and extract the tags this way:

curl -u MY_USERNAME:MY_PASSWORD https://api.del.icio.us/v1/tags/get | \
awk '{t=substr($3, 6, 30); t=substr(0, index(t, "\"")-1); print t}'

This should now give you only the tags in a newline separeted format, just like we need for dmenu!

So the next step would be launch firefox and view the links associated to the selected tag. To do this; save the command above into a file called: delicious-get_tags.run (remember to specify a shebang and chmod +x).
We then need to create a new script file called delicious-get_tags-dmenu.run (again chmod +x and specify a bash shebang) and enter this code:

firefox "http://delicious.com/MY_USERNAME/`/path/to/delicious-get_tags.run | dmenu`"

Now when you run this script you will get dmenu appear, select a tag and firefox should launch! :)
If you would like to launch this command using your standard dmenu instance; create a link to this script in a folder in your path, like so:

ln -s /path/to/delicious-get_tags-dmenu.run /usr/bin/delicious_get_tags

Now you can run your new dmenu from dmenu by selecting delicious_get_tags ! enjoy! ;)

Comments (View)
blog comments powered by Disqus