Archive your tomboy notes
Tomboy is my favorite note taking application. It’s as close as it can get to paper and an pencil. It’s a relatively new application so new features are still popping up here and there written by many different people. This lame script is my small contribution to this awesome piece of software.
A really cool thing about tomboy is its dbus interface, it allows interaction with tomboy without even looking into the source code.
Unfortunately tomboy doesn’t come with an archive feature, which means that either you need to keep whatever notes you might one day use in a big messy pile of notes or you delete it and regret it latter. The solution I came up with is simply archiving a snapshot of all my notes in a html file. Tomboy comes with an export to html feature but it only works for single notes. Luckily, if you export a note containing links to other notes, the linked notes will also be included in the same HTML file. That being said, the only thing we need to do is create a not with links to all other notes. Using tomboy’s dbus interface that’s a breeze.
#!/usr/bin/env python
#
# This script creates a tomboy note containing link to each other note
# so one can easily export all the notes to an HTML file
#
# author:Pedro
#
# Check out lamehacks.net for more lame scripts and stuff
import dbus, time
note_title = "Note Index"
# Get the D-Bus session bus
bus = dbus.SessionBus()
# Access the Tomboy D-Bus object
obj = bus.get_object("org.gnome.Tomboy","/org/gnome/Tomboy/RemoteControl")
# Access the Tomboy remote control interface
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
notes_links = ""
for note in tomboy.ListAllNotes():
notes_links += tomboy.GetNoteTitle(note) + " \n"
uri = tomboy.FindNote(note_title)
if uri == "":
uri = tomboy.CreateNamedNote(note_title)
tomboy.SetNoteContents(uri, note_title + "\n\n" + notes_links)
tomboy.DisplayNote(uri)
Run this script, a new note called Note index should have been created containng links to every other note. Export it to HTML and sabe it. I used python, but any language having a dbus library can be used.
NOTE: For some reason sometimes the script needs to be executed twice in order for the contents to be actually placed in the note. I believe this is some bug in Tomboy Notes.
Tags: dbus, linux, python, tomboy notes