def get_active_window_title(self):
    root = Popen(['xprop', '-root', '_NET_ACTIVE_WINDOW'], stdout=PIPE)
for line in root.stdout:
    m = re.search('^_NET_ACTIVE_WINDOW.* ([\\w]+)$', line)
if m != None:
    pass
Get active window title in X