How to get accurate window information (dimensions, etc.) in Linux (X)?

There are some command line programs that might help:

  • xwininfo: It gets you the size of the window excluding the decoration and the position absolute (to the screen) and relative (to the area for windows)
  • xdpyinfo: This gives far more information about your screen-device, than you ever want to know about. But it has somewhere in the output something like screen: #0 followed by dimension: 1024x768.

> precise window dimensions

The following example (will work at least in sh, bash and zsh) will print window geometry with and without frame for all windows with "KWrite" somewhere in title.

windows="$(wmiface findNormalWindows "KWrite" "" "" "" "" "")"
for window in $(echo $windows); do
{
  echo $window
  wmiface framePosition $window
  wmiface frameSize $window
  wmiface windowPosition $window
  wmiface windowSize $window
  echo
} done

> precise available screen space (excluding panels like gnome-panel)

xrandr

For example:

xrandr | head -n1 | cut -d, -f2 | cut -d" " -f3-5

Output in my case:

4400 x 2560

Not sure how to exclude panels - if you have more than one monitor, they can be even in middle of virtual screen, so screen geometry without panels can be more complicated than "available screen space".

> the ability to set a window to be a certain size, including decorations

wmiface setFrameGeometry $window $x $y $width $height

Read wmiface README for even more possible commands.