Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I get accurate window information in Linux? I know that I can use wmctrl to get a window's size, but the actual size of the window can vary due to window decorations. I need the following information and methods:

* precise window dimensions
* precise available screen space (excluding panels like gnome-panel)
* the ability to set a window to be a certain size, including decorations

What would be the best way to do this?

Thanks in advance!

share|improve this question
    
If you are interested more in the python side, we can migrate this to our sister site about programming, StackOverflow.com. Just let us know. –  Gnoupi Jul 15 '10 at 15:47
    
@Gnoupi: thanks, but this is actually a cross-post from SO, as a user suggested I might get a better answer here. The original question is at stackoverflow.com/questions/3233660/…. –  mellort Jul 15 '10 at 15:49
    
ok, I see. In this case, I think the python part of your question can be edited away. Answers on SU will most likely be using other commands, not programming. The question on SO should probably focus on asking how to do it in python. –  Gnoupi Jul 15 '10 at 15:54
1  
@Gnoupi: done. Thanks for the help. –  mellort Jul 15 '10 at 15:59
add comment

2 Answers

There are some programs on the linux-console, 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.
share|improve this answer
    
Is there a way to get information including the decoration? –  Victor Mar 27 '12 at 23:49
add comment

> 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.