Tomboy is an open source GNOME desktop note-taking application which is written in C# and utilizing the Mono runtime, Gtk# and the GtkSpell spell-checker.
The actual release of Tomboy which comes with Fedora 10 is version 0.12.0. This includes a comprehensive D-Bus interface which makes it possible to create, modify and display Tomcat notes from your shell scripts. This post provides an overview of the available D-Bus methods and includes a number of examples for you to experiment with. See my previous post on D-Bus scripting if you are unfamilar with the basic concepts of D-Bus scripting.
First we will list the available objects using qdbus. $ qdbus org.gnome.Tomboy / /org /org/gnome /org/gnome/Tomboy /org/gnome/Tomboy/RemoteControl
Next, we list all the available signals and methods for RemoteControl. $ qdbus org.gnome.Tomboy /org/gnome/Tomboy/RemoteControl method QString org.freedesktop.DBus.Introspectable.Introspect() method bool org.gnome.Tomboy.RemoteControl.AddTagToNote(QString uri, QString tag_name) method QString org.gnome.Tomboy.RemoteControl.CreateNamedNote(QString linked_title) method QString org.gnome.Tomboy.RemoteControl.CreateNote() method bool org.gnome.Tomboy.RemoteControl.DeleteNote(QString uri) method bool org.gnome.Tomboy.RemoteControl.DisplayNote(QString uri) method bool org.gnome.Tomboy.RemoteControl.DisplayNoteWithSearch(QString uri, QString search) method void org.gnome.Tomboy.RemoteControl.DisplaySearch() method void org.gnome.Tomboy.RemoteControl.DisplaySearchWithText(QString search_text) method QString org.gnome.Tomboy.RemoteControl.FindNote(QString linked_title) method QString org.gnome.Tomboy.RemoteControl.FindStartHereNote() method QStringList org.gnome.Tomboy.RemoteControl.GetAllNotesWithTag(QString tag_name) method qlonglong org.gnome.Tomboy.RemoteControl.GetNoteChangeDate(QString uri) method QString org.gnome.Tomboy.RemoteControl.GetNoteCompleteXml(QString uri) method QString org.gnome.Tomboy.RemoteControl.GetNoteContents(QString uri) method QString org.gnome.Tomboy.RemoteControl.GetNoteContentsXml(QString uri) method qlonglong org.gnome.Tomboy.RemoteControl.GetNoteCreateDate(QString uri) method QString org.gnome.Tomboy.RemoteControl.GetNoteTitle(QString uri) method QStringList org.gnome.Tomboy.RemoteControl.GetTagsForNote(QString uri) method bool org.gnome.Tomboy.RemoteControl.HideNote(QString uri) method QStringList org.gnome.Tomboy.RemoteControl.ListAllNotes() signal void org.gnome.Tomboy.RemoteControl.NoteAdded(QString uri) signal void org.gnome.Tomboy.RemoteControl.NoteDeleted(QString uri, QString title) method bool org.gnome.Tomboy.RemoteControl.NoteExists(QString uri) signal void org.gnome.Tomboy.RemoteControl.NoteSaved(QString uri) method bool org.gnome.Tomboy.RemoteControl.RemoveTagFromNote(QString uri, QString tag_name) method QStringList org.gnome.Tomboy.RemoteControl.SearchNotes(QString query, bool case_sensitive) method bool org.gnome.Tomboy.RemoteControl.SetNoteCompleteXml(QString uri, QString xml_contents) method bool org.gnome.Tomboy.RemoteControl.SetNoteContents(QString uri, QString text_contents) method bool org.gnome.Tomboy.RemoteControl.SetNoteContentsXml(QString uri, QString xml_contents) method QString org.gnome.Tomboy.RemoteControl.Version()
As a simple example of how to use a published method, we invoke the Version method to return the version of Tomboy that we are using. $ qdbus org.gnome.Tomboy /org/gnome/Tomboy/RemoteControl org.gnome.Tomboy.RemoteControl.Version 0.12.0
We can use dbus-send instead of qdbus as shown below but, as you can, see qdbus syntax is more compact. Also note that we have to use the session bus. $ dbus-send –type=method_call –session –print-reply \ –dest=’org.gnome.Tomboy’ /org/gnome/Tomboy/RemoteControl \ org.gnome.Tomboy.RemoteControl.Version 0.12.0
In the following example, we create the equivalant of “Hello World” using a note, display it for 5 seconds and then delete the note. #!/bin/bash DPATH=”/org/gnome/Tomboy/RemoteControl” INTERFACE=”org.gnome.Tomboy.RemoteControl” TMP=`qdbus org.gnome.Tomboy ${DPATH} ${INTERFACE}.CreateNamedNote “My Note” 2>/dev/null` RESULT=$? if [[ $RESULT != 0 ]] then exit 1 fi # figure out note uri string which is of the form # note://0xaf3356abcdefg OID=${TMP#note:} # set the contents of