#!/usr/bin/python3

import pyatspi

def listener(e):
    try:
        isSelected = e.source.getState().contains(pyatspi.STATE_SELECTED)
    except:
        return
    print("%s - event matches state: %s" % (e.source, isSelected == e.detail1))

pyatspi.Registry.registerEventListener(listener, "object:state-changed:selected")
pyatspi.Registry.start()
