In Bash on Ubuntu 14.04, Unity, How can I get the total size of an open window including borders and title?

419 Views Asked by At

I have used the answer to https://unix.stackexchange.com/questions/14159/how-do-i-find-the-window-dimensions-and-position-accurately-including-decoration in my bash scripts, and had good success with my Silentcast application on Xfce, but now that others are using it, they are finding some problems in Ubuntu 14.04, Unity. Here is one problem caused by the output of:

xwininfo -id $(xdotool getactivewindow)

Showing:

Relative upper-left X: 0 Relative upper-left Y: 0

Which I use to calculate the width of the borders and the height of the titlebar. They should not be 0.

Does anyone know how to get the width of the window borders and the height of the titlebar in Unity for Ubuntu 14.04.

Or, how to directly get the full window dimensions?

I have filed a bug against xorg for the xwininfo package https://bugs.freedesktop.org/show_bug.cgi?id=84348

I have also found out information about creating your own theme in Unity under Ubuntu 14.04: https://wiki.ubuntu.com/Unity/Theming

It seems like the answer is in that theming page somewhere, but I don't understand it yet especially since I don't use Ubuntu or Unity.

1

There are 1 best solutions below

3
Treviño On BEST ANSWER

This applies also to compiz. There are a couple of ways you can get these informations in some ways:

wnckprop --xid=$(xdotool getactivewindow)

Otherwise, you can just mix the Absolute value you get from xwininfo together with the size of the decorations that are accessible using:

xprop _NET_FRAME_EXTENTS --xid=$(xdotool getactivewindow)

As you can read in the freedesktop documentation, that property lists the sizes in this order: left, right, top, bottom.

For your information, if you want to get the full frame size, including the input area around the window, you can use xwininfo -frame.