[How To] Create A Window Geometry Software

Small GUI tool to get both the net size and the real size of a window (dynamically updated)

As explained further below in “Explanation”, both wmctrl and xdotool return a slightly incorrect windowsize.

enter image description here

The script (indicator) below will show both the “real” size and the net size of a window in the panel.

The script

How to use

  1. The script needs xdotool to be installed:
  2. Copy the script into an empty file, save it as getwindowsize.py
  3. Test- run the script from a terminal window by the command:
  4. The script picks the focussed window to dynamically show the net windowsize (as in the output of both wmctrl and xdotool) and the real window size, including decorators etc.

    If you close the targeted window, the indicator shows a message:

    enter image description here

  5. If all works fine, add it to a shortcut key: choose: System Settings > “Keyboard” > “Shortcuts” > “Custom Shortcuts”. Click the “+” and add the command:

Explanation

The window size, as it is displayed by both wmctrl and xdotool

…is slightly incorrect

You mention:

Ideally, that tool would deduct the size of the Ubuntu’s menu bar

The complete story is that both wmctrl -lG and xdotool getwindowgeometry return the size of the window without menu bar, or, as it is explained in this answer:

What’s happening is that wmctrl is returning the geometry of the window inside the decorations (i.e. not including the title bar and borders)

How to get the correct, “real” size

To get the information correctly, we can run

This will output like:

Here we get the values we need to add to the window’s size, as output from wmctrl and xdotool, to the left, right, top and bottom of the window.

In other words, in this case, if a wmctrl shows a size of 200×100, the real size is 200×128.

Note

As suggested by OP, the user can also pick a window after the indicator was started, by replacing:

by:

In the script, either one of these lines can be uncommented.

Source :

AskUbuntu

You might also like