7

How can you check if a window is minimized via the terminal in linux?

htmlajax
  • 71
  • 1
  • 2

3 Answers3

1
if xwininfo -all -id $windowIdGoHere |grep "Hidden"; then
  echo "is hidden"
fi
Aquarius Power
  • 3,729
  • 5
  • 32
  • 67
1
xwininfo -name 'Window Title' | grep 'Map State:'

Look for IsViewable versus IsUnMapped; these come from the map_state field returned by XGetWindowAttributes.

(At least, that works with traditional window managers; I don't know if Compiz does screwy stuff to allow for thumbnailing minimized windows.)

ephemient
  • 198,619
  • 38
  • 280
  • 391
  • 1
    It won't work with Enlightenment (e17), where the `map_state` seems to be always `IsViewable` (this is a feature, which allows for instance [screen captures of hidden windows](http://unix.stackexchange.com/a/93159/26952)). – Skippy le Grand Gourou Oct 01 '13 at 13:55
  • Doesn't work either on Ubuntu 13.04 with Compiz. The result for some window is `Map State: IsViewable`, for others is `Map State: IsUnMapped`, but this field seems not related to the actual visibility (normal or minimized) of a window. – Avio Nov 18 '13 at 14:09
0
[ $(xwininfo -id 0x60001d -all | awk '/Maximized/{print}' | wc -l) -eq 2 ] && echo Maximized

where 0x60001d is window ID. See xwininfo -h for other ways to identify a window for testing.

Simon
  • 158
  • 1
  • 7