Ubuntu 14.04 Unity Theme - getting the decorations size from a bash script

Asked by Colin Keenan

For some other desktops, I have had success getting the decoration size from a bash script by using xwininfo. However, xwininfo incorrectly reports 0 for all decorations in Unity windows in Ubuntu 14.04. I have filed this bug against xorg:
https://bugs.freedesktop.org/show_bug.cgi?id=84348

I have seen that it is possible for users to use custom themes as discussed on here: https://wiki.ubuntu.com/Unity/Theming

Before seeing that questions should be asked here, I sent an email to 3v1n0: https://launchpad.net/~3v1n0, who had last edited the Theming page.

I hope he or someone else can tell me how a bash script can get the window decoration sizes of an active window. I personally use Xfce on Arch, so this isn't that easy for me to investigate.

From the Theming page, I see that if not changed, the decorations would add 28 to the top, 1 all around, and 10 more to the bottom for some mysterious extra input area.

I would like a bash script to be able to look up those numbers in case they had been modified though.

Question information

Language:
English Edit question
Status:
Solved
For:
Unity Edit question
Assignee:
No assignee Edit question
Solved by:
Marco Trevisan (Treviño)
Solved:
Last query:
Last reply:
Revision history for this message
Colin Keenan (colinkeenan) said :
#1

I have been looking around for the Unity theme files by running Ubuntu 14.04 in Virtual Box, and found them in /usr/share/themes. But, how do I know which theme is in current use from a bash script? For example, if it is Ambience, then the information I need is contained in the file:

/usr/share/themes/Ambiance/gtk-3.0/apps/unity.css

So, now my question can be reduced to:

How does my bash script find out the location of the unity.css file in current use? It's not listed in the output of `env`.

Revision history for this message
Best Marco Trevisan (Treviño) (3v1n0) said :
#2

As replied in StackOverflow:

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)

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

    xwininfo -frame

Revision history for this message
Colin Keenan (colinkeenan) said :
#3

Excellent.

Just to be sure I understand the output of

    xprop _NET_FRAME_EXTENTS --xid=$(xdotool getactivewindow)

I think it's giving me the widths in pixels of the following decoration edges:

    left ,right, top, bottom

So that:

    _NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 28, 0

would mean the title height is 28 pixels and all the borders are 0 pixels.

Is that correct?

And then, I should combine that with the Absolute value from
    xwininfo -frame

(I am going to prefer xprop/xwininfo over wnckprop because wnckprop seems to be part of an excessively large package.)

Revision history for this message
Colin Keenan (colinkeenan) said :
#4

I am going to mark this solved, but I do want to be sure the order of the numbers is left, right, top, bottom. I mean that makes sense, but I can't figure out how to check the documentation for it. Almost always, all the borders will be the same other than top, but just in case there's a lopsided theme in use, I would like to know.

Revision history for this message
Colin Keenan (colinkeenan) said :
#5

Thanks Marco Trevisan (Treviño), that solved my question.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) said :
#6

As per the documentation¹, yes the order is left, right, top, bottom

[1] http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html#idm140238712267120

Revision history for this message
Colin Keenan (colinkeenan) said :
#7

Thank you again.