Specifying X windows' geometry in the coordinates obtained from wmctrl
In the X documentation I read that the Width
, Height
, Xposition
and Yposition
coordinates must be specified in terminal characters when using:
gnome-terminal --geometry=WidthxHeight+Xposition+Yposition
If I use as input coordinates those that I get from a wmctrl -lG
output (not sure if wmctrl
uses pixels, terminal characters or something different as geometrical units), I don't get the expected results. I.e. the geometry coordinates output by wmctrl -lG
and the ones a user can specify with gnome-terminal --geometry
turn out to be different.
Is there anything I am doing wrong? Any thoughts?
Thanks
Solution 1:
The --geometry
option for gnome-terminal
is actually measured in characters, rather than pixels. For example, to get an 80 column terminal only 10 lines high, you can launch gnome-terminal
like this:
gnome-terminal --geometry 80x10
The terminal will resize in increments of the font character size, which it communicates to the Xserver using WM_NORMAL_HINTS
. You can examine these using the xprop
command. For example, here I find a Terminal window id, and ask xprop about it:
$ wmctrl -lG | tail -n1
0x06400021 0 592 314 580 338 myhostname kees@myhostname: ~
$ xprop -id 0x6400021
...
WM_NORMAL_HINTS(WM_SIZE_HINTS):
program specified minimum size: 48 by 16
program specified resize increment: 7 by 14
program specified base size: 20 by 2
window gravity: NorthWest
...
In the above case, the font size is 7 by 14 pixels. So if I wanted a 70 by 140 pixel Terminal, I could run gnome-terminal --geometry 10x10
(though it would be 20 x 2 pixels larger than that based on the window manager decorations, etc, as seen in the "specific base size" above).