#!/usr/bin/python3

import pyatspi

def listener(e):
    if e.host_application.name != "gnome-shell":
        return

    if not e.detail1 and e.type.startswith("object:state-changed"):
        return

    print(e.source, e.type)

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