I'm trying to build a script that checks that windows under XFCE are minimized before displaying a window I've chosen (it's a part from a bigger project)
I tried to recover the count of the open windows with wmctrl but these are not the minimized windows :
CURRWORKSPACE=$(wmctrl -d | grep '*' | cut -d ' ' -f1)
OPENWINDOWS=$(wmctrl -l | cut -d ' ' -f3 | grep $CURRWORKSPACE | wc -l)
I also try with xdotool, but without success :(
I was wondering if you knew of any way to get this information. I'm on XFCE, but another way with any tool would be great
Many thanks !
Given a window and its id as listed by
wmctrlyou can use the following function to determine whether that window is minimized. Note that minimized windows are called iconic in X.In order to count open windows you can loop over the list of window ids.
At least on my desktop environment (Cinnamon) some "windows" were always open. These windows are for instance the Desktop. I adjusted the function by filtering out these windows before looping over them. Since they were sticky and I normally don't use sticky windows I just neglected all sticky windows:
$(wmctrl -l | grep -vE '^0x\w* -1' | cut -f1 -d' ').You can adjust the filtering to your needs. In this case all open and non-sticky windows on all workspaces/desktops are counted.