#!/usr/bin/python3

import pyatspi

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

    state = e.source.getState()
    print("%s expandable: %s expanded: %s" % \
         (e.source,
          state.contains(pyatspi.STATE_EXPANDABLE),
          state.contains(pyatspi.STATE_EXPANDED)))

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