Save Text Selection as a Tomboy Note with Autokey

Dmitri Popov

Productivity Sauce

Jun 16, 2011 GMT
Dmitri Popov

Since Autokey supports Python, you can automate virtually any task using simple (or complex) scripts. A recent addition to my ever-growing collection of handy Autokey scripts is a relatively simple solution for saving text selections as Tomboy notes:

import sys, dbus, gobject, dbus.glib 
snippet = clipboard.get_selection() 
retCode, title = dialog.input_dialog("Note Title", "Enter note title:") 
bus = dbus.SessionBus() 
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl") 
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl") 
newnote=tomboy.CreateNamedNote(title) 
tomboy.SetNoteContents(newnote, 
  tomboy.GetNoteTitle(newnote) + "\n\n" + snippet) 
tomboy.DisplayNote(newnote)

The script above is largely based on stuff from the Using the Tomboy D-Bus interface article published on Ars Technica. All I had to do is to tweak a few things; for example, I added an input dialog that prompts the user to specify a note title.

comments powered by Disqus

Issue 19: Linux Shell Handbook 5th Ed./Special Editions

Buy this issue as a PDF

Digital Issue: Price $15.99
(incl. VAT)

News