Resizing a window to a set size in Linux
wmctrl -r ":ACTIVE:" -e "0,$(xdotool getactivewindow getwindowgeometry|egrep -o '[0-9]+,[^ ]+'),970,600"
targets an active window (i.e, the terminal used for the command) resizes to 970 (width) and 600 (height)
Use the wmctrl command:
To list the windows:
$ wmctrl -l
0x00c00003 -1 rgamble-desktop Bottom Expanded Edge Panel
0x00c00031 -1 rgamble-desktop Top Expanded Edge Panel
0x00e00022 -1 rgamble-desktop Desktop
0x0260007c 0 rgamble-desktop Google - Mozilla Firefox
To resize a window based on its title:
wmctrl -r Firefox -e 0,0,0,640,480
The arguments to the resize option are gravity,X,Y,width,height
so this will place the window at the top-left corner of the screen and resize it to 640X480.
Using wmctrl, there is also some pre defined states:
If a window is currently in the state maximized
, it won't respond to a resizing in pixels using the -e
parameter^. This is where the -b
param is useful.
The -b option expects a list of comma separated parameters: "(remove|add|toggle),PROP1,PROP2]"
Example:
wmctrl -r Firefox -b toggle,maximized_horz
States available:
wmctrl -r Firefox -b toggle,maximized_vert
----- ---------------
remove modal
add sticky
toggle maximized_vert
maximized_horz
shaded
skip_taskbar
skip_pager
hidden
fullscreen
above
below
About the precise question, the -e param allow resizing by values as follow:
Gravity, position X, position Y, window width, window height
// gravity,x,y,w,h
wmctrl -r "Resizing" -e 0,0,0,640,480