Erik I
Erik I

Reputation: 1072

Resizing a window to a set size in Linux

Anyone knows a good way to resize any window to for example 640x480?

Reason is, of course, screencasting.

Under windows I've used ZoneSize from donationcoder. (Btw: For Firefox it's easy, just use the web developer toolbar.)

Upvotes: 46

Views: 41952

Answers (4)

BZZZZ
BZZZZ

Reputation: 61

sh script that uses wmctrl to resize windows:

#!/usr/bin/sh
wmctrl -l
echo
read -p "window id -> " wid
read -p "width -> " ww
read -p "height -> " wh
wmctrl -i -r "$wid" -e "0,0,0,$ww,$wh"
echo "Done!"

Upvotes: 2

user18510353
user18510353

Reputation: 19

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)

Upvotes: 1

NVRM
NVRM

Reputation: 13083

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

Upvotes: 6

Robert Gamble
Robert Gamble

Reputation: 109032

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.

Upvotes: 76

Related Questions