#!/usr/bin/python

import pyatspi

def onFocused(event):
    if not event.detail1:
        return

    print(event)

pyatspi.Registry.registerEventListener(onFocused, "object:state-changed:focused")
pyatspi.Registry.start()
