Is there a way to create a callback that will be called every time the active window changes, passing in information like class, title, etc.? I can find the current active window like this:
That’s unnecessarily complicated. MetaDisplay has a focus-window property that you can use directly. You can use the notify signal to monitor changes:
global.display.connect('notify::focus-window',
() => console.log(`Focus changed to ${global.display.focus_window}`));