Python – How to tell if a full-screen application is running

linuxpythonx11

Is it possible in python to tell if a full screen application on linux is running?
I have a feeling it might be possible using Xlib but I haven't found a way.

EDIT: By full screen I mean the WHOLE screen nothing else but the application, such as a full-screen game.

Best Answer

If all Window Managers you're interested in running under support EWMH, the Extended Window Manager Hints standard, there are elegant ways to perform this (speaking to Xlib via ctypes, for example). The _NET_ACTIVE_WINDOW property of the root window (see here) tells you which window is active (if any); the _NET_WM_STATE property of the active window is then a list of atoms describing its state which will include _NET_WM_STATE_FULLSCREEN if that window is fullscreen. (If you have multiple monitors of course a window could be fullscreen on one of them without being active; I believe other cases may exist in which a window may be fullscreen without being active -- I don't think there's any way to cover them all without essentially checking _NET_WM_STATE for every window, though).