GTK Recently Used updated with inotify!

Heres a cute hack, an easy way to make any file you open/change from the command line appear in your GTK file widget's "Recently Used" list, it uses python's pyinotify package available in apt, and pythons python-gtk2 package.

Something that's very handy, for example when you are editing something on the command line and attaching to an email and need to browse to the location, or when you've wget'ed a file and need to open it from a gnome application, the list goes on!

This is something i've been thinking about for a while where windows might be better than linux on the desktop when it comes to working with the "contextual desktop", that is to say, the desktop is a little bit more aware about what you're doing by just showing options that are within your current context/train-of-thought.

infact it was handy even when creating this article, i could attach the python script without having to browse to it, because it was already in my "Recent Documents" :)

you could modify this script to only include files of a certain mime type, files greater than a certain size, files of a regex etc just to tidy it up so you don't get spurious entries showing up in your gtk/gnome Recently Used list

Note: Don't forget to edit the path's in the python script to reflect something local and useful to you, if you have a large home directory like i do, you probably dont want to watch all the directories as it will latch onto all the cache writings etc in your ~/.* files.

Just be sure to customise these entries...

wdd = wm.add_watch('/home/dgtlmoon/Desktop/', mask, rec=True, auto_add=True)
wdd = wm.add_watch('/home/dgtlmoon/workspace/', mask, rec=True, auto_add=True)
wdd = wm.add_watch('/home/dgtlmoon/Downloads', mask, rec=True, auto_add=True)

Script is attached to this article.

AttachmentSize
recent.png33.27 KB
inotify_gnome.py.txt1.37 KB
recent2.png3.98 KB