Script to move and resize a window in Linux

Fri Oct 22, 2010

I’m working on creating several educational video clips (screencasting). I’m using Kazam to do the recording. Kazam records the whole screen (1280x1024). Later I crop those videos to 1280x720. I want that the cropping can be automated. I don’t want to set the crop area by hand each time. To do this I must be sure the area I want to crop does not change from video to video.

That’s why I created a script that moves and resizes the application I want to record, so it’s always on the same place, with the same size. My script is called resize-gimp.sh and it should be executable (terminal: chmod +x resize-gimp.sh).  This is the script:

wmctrl -r GIMP -e 0,0,0,1280,720
wmctrl -a GIMP

If wmctrl is missing from your computer type “sudo apt-get install wmctrl” in the terminal.

The word “GIMP” appears twice in the script. It’s used to find which window you want to resize. You can replace it with any other name like “Office” or “Firefox”. Just observe the title of the window you want to resize. Choose a word that is only present in that window, and not in others. The first line in the script sets gravity to 0, moves the window to 0,0 and resizes it to 1280,720. The second line brings the window to front.

Then I added a new shortcut so I can easily execute the script by pressing a key combination. This is done in “System > Preferences > Keyboard Shortcuts”, in the top menu in Ubuntu.

Categories: text Tags: script ubuntu software Places: unimportant

left arrow down arrow right arrow