Schurger.org

1 août 2008

Copy X selection to Tomboy

Filed under: Non classé — Jean Schurger @ 19:58

Put that code into a script, set a keybinding desktop wide, and tomboy notes will be created, containing your current X selection, simple, easy, and terribly  usefull ! (needs xsel)

#!/usr/bin/env python

import sys, dbus, dbus.glib
from datetime import datetime
from subprocess import Popen, PIPE

bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
p = Popen(args=["/usr/bin/xsel"], shell=False, stdout=PIPE)
p.wait()
sel = p.stdout.read()
if sel:
    now = datetime.now().ctime()
    new_note = tomboy.CreateNote()
    tomboy.SetNoteContents(new_note, "X %s\n\n%s" % (now, sel))
    tomboy.AddTagToNote(new_note, "X")

Powered by WordPress