January 26, 2008

Wrapping workspaces in Gnome

One source of frustration sometimes with gnome is that there is no way to wrap workspaces like in KDE, compiz or even the other window managers like XFCE. This means that, if like me you use 'move to workspace right' and 'move to workspace left' frequently while working, it can frustrating not to be able to get back to workspace 1 from the last one in one simple step.

Searching for some way to do this, I came upon this post describing the use of wmctrl to do this. I had never heard of wmctrl before, but it turns out to be pretty cool. So go ahead, install it (sudo aptitude install wmctrl) and now -


raja@eee:~$ wmctrl -d
0 - DG: 800x480 VP: N/A WA: 0,2 800x476 Desk 1
1 - DG: 800x480 VP: N/A WA: 0,2 800x476 Desk 2
2 - DG: 800x480 VP: N/A WA: 0,2 800x476 Desk 3
3 * DG: 800x480 VP: 0,0 WA: 0,2 800x476 Desk 4

raja@eee:~$ wmctrl -s 1 && wmctrl -d
0 - DG: 800x480 VP: N/A WA: 0,2 800x476 Desk 1
1 * DG: 800x480 VP: 0,0 WA: 0,2 800x476 Desk 2
2 - DG: 800x480 VP: N/A WA: 0,2 800x476 Desk 3
3 - DG: 800x480 VP: N/A WA: 0,2 800x476 Desk 4



As we can see, 'wmctrl -d' lists the desktops and places an asterisk to indicate the current desktop. And 'wmctrl -s n' allows us to switch to the desktop n, with the desktops being numbered from 0 onwards.

With this knowledge, it is easy to write a couple of scripts to switch to the desktop on the left and the one on the right, with wrapping enabled.


#!/bin/bash

#ws_wrap_lt.sh

#get number of workspaces
ws=$(wmctrl -d | wc -l)

#current workspace index
cws=$(wmctrl -d | awk '/\*/ {print $1}')

#work space on left
lws=$(($cws-1))

#wrap if required
if [ $lws = -1 ]; then
lws=$(($ws-1))
fi
echo $lws

#change to next workspace
wmctrl -s $lws


and ..


#!/bin/bash

#ws_wrap_rt.sh

#get number of workspaces
ws=$(wmctrl -d | wc -l)

#current workspace index
cws=$(wmctrl -d | awk '/\*/ {print $1}')

#work space on right
rws=$(($cws+1))

#wrap if required
if [ $rws = $ws ]; then
rws=0
fi

#change to next workspace
wmctrl -s $rws


Save the files somewhere and now you can use gconf-editor to map commands to these scripts. Then you can set up a desired key or key combination to run these commands. An option is also to use only one of the scripts and rotate through the workspaces with one key. On the eeepc, I have mapped the 'menu' key to ws_wrap_rt.sh and use just that key to get to any workspace I want. If you use only two workspaces,one key works to toggle the workspaces.

January 14, 2008

Ubuntu on my eee

I bought an eeepc a couple of days back after my thinkpad was stolen. While it is considered to be a secondary computer at best, it seemed worthwhile trying it out. I think it was an unfortunate choice of linux distribution by asus and there was no way I was going to be stuck with xandros. So the decision was only between Ubuntu and Archlinux. I decided on the former because it seemed to be better documented on the eee and would take less time to set up (so I thought).

It was finally 4 hours before I had Ubuntu running. Briefly, what learned were -

1. Netboot does not work
Well, the eee can PXE boot once boot from lan is enabled in the bios, but the netboot image of either gutsy or feisty dont seem to have the modules for the ethernet card, so its a no-go after that.

2. Cannot find casper/.vml
If you followed the instructions here to make a bootable USB drive and get the error message 'cannot find casper/.vml' when trying to boot, just move vmlinuz and initd.img from the casper folder into the root directory of the usb drive and then modify the locations accordingly in syslinux.cfg.

3. Booting from the usb drive
I struggled a bit to boot from the usb drive - it wouldnt boot even after setting 'removable drive' as the first in boot order in the bios. It seems like the usb drive was being added as a second hard drive. The more reliable way to boot into the drive was to hold down the Esc key which offers a choice of devices to boot from.

4. Nothing older than gutsy
I had a gutsy beta iso already downloaded, so used it the first time. Which was unfortunate because it does not have the module for the ethernet and so I ended up without a working wired or wireless connection. Re-installing with the final gutsy iso solved the issue.

After all these unexpected difficulties, I finally had Ubuntu on the eee and spent the next day tweaking it. It boots in just under 40 seconds and seems to last about 2hrs30min on the battery.

All in all, it looks like a good deal!