#!/usr/bin/python3

import gi
gi.require_version('Atspi', '2.0')

import pyatspi

def listener(e):
    try:
        # Because if you're using an accessible terminal app, printing
        # events will cause the terminal app's scroll bar to scroll,
        # resulting in value-change events emitted by the scroll bar.
        if e.source.getRole() == pyatspi.ROLE_SCROLL_BAR:
            return
    except:
        return

    print('%s %s %s (%s, %s, %s)' % (e.host_application, e.source, e.type, e.detail1, e.detail2, e.any_data))

pyatspi.Registry.registerEventListener(listener, 'object:property-change:accessible-value')
pyatspi.Registry.start()
