Interacting with Getting Things GNOME! via dbus

If you are on this page, you're probably interested in integrating some uber-cool software with GTG. First of all, kudos for that. It's good karma.

Python

Very simple script listing the "Active" tasks (that are the ones *not* marked as done or dismissed)

   1 import dbus
   2 bus = dbus.SessionBus()
   3 obj = bus.get_object("org.GTG", "/org/GTG")
   4 gtg = dbus.Interface(obj, "org.GTG")
   5 for t in gtg.get_tasks(): 
   6     print t
   7     print t["title"]

As you can see if you run the code above, tasks are simple dictionaries. The next example is a little less trivial:

   1 #!python
   2 import dbus
   3 bus = dbus.SessionBus()
   4 obj = bus.get_object("org.GTG", "/org/GTG")
   5 gtg = dbus.Interface(obj, "org.GTG")
   6 for tid in gtg.get_task_ids("Active, Dismissed"): 
   7     #the task id is a string which identifies the task
   8     print tid
   9     #if you want to get task properties, you need to do
  10     task = gtg.get_task(tid)
  11     #the task object is a simple dictionary (print it 
  12     #  to see the key values)
  13     print task["title"]
  14     # once you modify that dictionary, you can feed it back to
  15     # GTG by:
  16     # task["title"] = "new_title"
  17     # gtg.modify_task(tid, task)
  18    # these lines are commented because they WILL modify your GTG data

Now you're ready for the real stuff (from Ryan Paul a.k.a. segphault):

   1 #!/usr/bin/env python
   2 
   3 import dbus
   4 
   5 bus = dbus.SessionBus()
   6 obj = bus.get_object("org.GTG", "/org/GTG")
   7 gtg = dbus.Interface(obj, "org.GTG")
   8 
   9 for t in gtg.get_tasks(): print t
  10 
  11 for t in gtg.get_tasks_filtered([], ["Active"], False, False):
  12   print t["id"], t["title"], t["tags"]
  13   
  14 for t in gtg.get_task_ids_filtered([], ["Active"], False, False):
  15   print t
  16 
  17 t1 = gtg.new_task(
  18     "Active", # status
  19     "This is another test", # title
  20     "2009-07-10", # due date
  21     "2009-07-07", # start date
  22     "", # finish date
  23     ["@ars"], # tags
  24     "This is more test content!", # text
  25     []) # subtask ids
  26 
  27 t2 = gtg.new_task(
  28     "Active", # status
  29     "This is a test", # title
  30     "2009-07-10", # due date
  31     "2009-07-07", # start date
  32     "", # finish date
  33     ["@ars", "@article"], # tags
  34     "This is test content!", # text
  35     [t1["id"]]) # subtask ids
  36 
  37 for t in gtg.get_tasks():
  38   if "test" in t["title"]:
  39     gtg.delete_task(t["id"])
  40 
  41 tid = "4@1"
  42 
  43 if gtg.has_task(tid):
  44   t = gtg.get_task("4@1")
  45   t["title"] = "I've changed the title!"
  46   t["tags"].append("@test")
  47   gtg.modify_task(tid, t)
  48 
  49 for t in gtg.get_tasks():
  50   if "Qt" in t["title"]:
  51     gtg.open_task_editor(t["id"])
  52 
  53 gtg.hide_task_browser()
  54 #gtg.show_task_browser()

Documentation

Not much yet, but feel free to fill in the gaps! All the function you can exploit are in this file: GTG-dbuswrapper

Apps that interface with GTG

  • docky
  • cairo dock (under development)
  • mutt (via cli gtg_new_task)

Apps/GTG/dbus (last edited 2015-01-06 10:33:36 by OliverPropst)