Python wnck Gnome 3

I have this code

#!/usr/bin/env python

import gi
gi.require_version('Wnck', '3.0') 
from gi.repository import GLib, Wnck  

def on_active_window_changed(screen, previously_active_window):
    screen.force_update()
    print(screen.get_active_window().get_name())

screen = Wnck.Screen.get_default()
screen.connect('active-window-changed', on_active_window_changed)

loop = GLib.MainLoop(None)
loop.run()

Run from a bash terminal, it then prints the name of any window I click on (active window). However, when I click on the Gnome desktop, it just prints the name of the last window. I guess the desktop isn't a window. (I don't know) How can I detect this (desktop being active)? Another library maybe or is it not possible? Thanks

728x90

0 Answers Python wnck Gnome 3