Find out if all windows are minimized
The existing answer mentions the right tools, but has quite a few issues, and won't work as it is.
A few important ones:
When using:
s = Wnck.Screen.get_default()
In a "standalone" situation (not from an existing loop), you need to add (see further below)*:
s.force_update()
is_minimzed()
is a method, and won't work without ()
The answer is not usable in another situation than OP's
A general script to just see if all windows are minimized would then be:
#!/usr/bin/env python3
import gi
gi.require_version('Wnck', '3.0')
from gi.repository import Wnck
s = Wnck.Screen.get_default()
# when not run from a loop, tell it to force_update
# else there will be no output
s.force_update()
all_minimized = True
# go through all windows
for window in s.get_windows():
# exclude windows like the desktop etc.
if window.get_window_type() == Wnck.WindowType.NORMAL:
# see if it is minimized
if not window.is_minimized():
# if any of the windows is not minimized -> all_minimized = False
all_minimized = False
print(all_minimized)
from here:
Common Pitfalls
While the API provided by libwnck should be mostly straight-forward in general, a few pitfalls are often hit by users of the library.
Explicit fetching of information
At its creation, a WnckScreen object will not have fetched information from the X server. If queried immediately after its creation (via wnck_screen_get_windows() or wnck_screen_get_workspaces(), for example), the WnckScreen object will look like there are no workspaces nor windows on the screen. This information is fetched in the main event loop with an idle source, to avoid an expensive synchronous operation on startup. If no main event loop is used, or if the information is needed as soon as possible after the creation of the object, wnck_screen_force_update() can be used to explicitly fetch the information.