Tomboy encryption plugin-like thing
Here's a little python program I made to ROT13 notes in Tomboy automagically. To use it, type the magic word (SECRET here) at the end of a note and after a short wait your note will be encoded / decoded. :)
It uses a daemonize function I found here.
It will crash in notes that have bullets (or other unicode characters I assume) because I'm currently too lazy to learn enough about unicode to fix it. :P
import dbus, gobject, dbus.glib
bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Tomboy","/org/gnome/Tomboy/RemoteControl")
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
def onNoteSaved(n):
title = tomboy.GetNoteTitle(n)
contents = tomboy.GetNoteContents(n,utf8_strings=True)
if contents.endswith("SECRET"):
code = contents.find("\n\n")
code = contents[code:-3]
crypt = code.encode('rot13')
con = title+crypt
tomboy.SetNoteContents(n,con,utf8_strings=True)
bus.add_signal_receiver(onNoteSaved,dbus_interface="org.gnome.Tomboy.RemoteContr
ol",signal_name="NoteSaved")
def daemonize(func):
import os
import sys
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError, e:
print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
os.chdir("/")
os.setsid()
os.umask(0)
try:
pid = os.fork()
if pid > 0:
print "Daemon PID %d" % pid
sys.exit(0)
except OSError, e:
print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
func()
daemonize(gobject.MainLoop().run)



