Reply to comment

danigm's picture

Como todo ser humano tengo una gran lista de cosas por hacer, también llamada TO-DO list. Hace algún tiempo empecé a utilizar tomboy para tomar notas y tener apuntado cosas por hacer, pero nunca me acuerdo de mirarlo, por lo tanto el otro día decidí hacer un sencillo script que cada cierto tiempo me recordara mi TO-DO list.

Para conseguirlo he utilizado pynotify para mostrar un mensajito en el escritorio cada 10 minutos, y he realizado consultas al servicio DBUS que ofrece tomboy para encontrar la nota con título TODO y coger el texto que hay en esta.

La idea es lanzar este script al iniciar el escritorio para así tenerlo en segundo plano mostrando mensajitos cada cierto tiempo.

Luego pensé que podía hacer lo mismo con los TODO de sweetter.net. Así que lo he integrado con el script utilizando el modulo pysweetter que tira del servicio XML-RPC. Por otra parte he tenido que implementar una función especifica para el servicio xmlrpc de sweetter.

Aquí una imagen del tema en acción:



frontal

Y para quien esté interesado, aquí está el código:

  1. #!/usr/bin/python
  2.  
  3. import gtk, pygtk
  4. pygtk.require('2.0')
  5.  
  6. import dbus
  7. import gobject
  8. import time
  9. import pynotify
  10.  
  11. from pysweetter import Sweetter
  12.  
  13. session_bus = dbus.SessionBus()
  14. uri = 'org.gnome.Tomboy'
  15. path = '/org/gnome/Tomboy/RemoteControl'
  16. sleep_time = 10 * 60
  17.  
  18. pynotify.init("Tomboy TODO notification")
  19. USER = 'danigm'
  20.  
  21. while True:
  22. try:
  23. tomboy = session_bus.get_object(uri, path)
  24. note_uri = tomboy.FindNote('TODO')
  25. all_text = tomboy.GetNoteContents(note_uri)
  26. all_text = all_text.split('\n')
  27. except:
  28. all_text = []
  29.  
  30. try:
  31. s = Sweetter()
  32. todo_list = s.get_TODO_list(USER)
  33. all_text.append('\nSweetter TODO\n')
  34.  
  35. for i, sweet in enumerate(todo_list):
  36. todo = '%d <a href="http://sweetter.net/%s?todo=1">%s</a>' % (i+1, USER, sweet.sweet)
  37. all_text.append(todo)
  38. except:
  39. pass
  40.  
  41. note = pynotify.Notification("TODO list",
  42. '\n'.join(all_text[1:]))
  43.  
  44. helper = gtk.Button()
  45. icon = helper.render_icon(gtk.STOCK_FILE,
  46. gtk.ICON_SIZE_DIALOG)
  47. note.set_icon_from_pixbuf(icon)
  48.  
  49. note.set_timeout(30000)
  50. note.show()
  51.  
  52. time.sleep(sleep_time)

Y para los más curiosos todavía aquí un repositorio del código:
bzr branch http://repo.danigm.net/todo-reminder

Los parches y comentarios son bienvenidos.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <python>, <php>, <java>, <c>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.