Posterous theme by Cory Watilo

Filed under: scripts

Script to move and resize a window in Linux

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 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.

Ubuntu (Nautilus) script to convert .webloc files

Screenshot

A few days ago I bought a new laptop. I installed Ubuntu 10.04, and now I'm migrating my files from my iMac to this laptop. I had some .webloc files which Ubuntu didn't understand, so I wrote a small script that I can run just doing a right click on the .webloc file to convert it to a valid Nautilus url-link file. I do plan to learn Python, but I used PHP since that's what I know. You are welcome to port it to any other language.

Read the rest of this post »