Note: This post does not talk about how to give your Ubuntu taskbar a Windows 7 look, you can download dockbarx themes and try them out yourself.

I normally do not have much love for windows because life for a web dev is generally easier on *nix platforms, but there is one feature that I really dig in Windows 7. The ability to pin items to your taskbar, and then switch between them using Win+[1..9] keys. This is very productive because I always know that my IDE will be running on Win+3, browser on Win+1, mail on Win + 2 etc. The Gnome/XFCE taskbar is really clunky, it hasn’t evolved in ages.

Anyhow, getting back to the original post, so you like those Win+n hotkeys, but don’t want to make a pact with the devil? Read on…

To get the same behaviour on gnome/xfce, we’ll need:

  1. A taskbar that lets you pin items (DockbarX)
  2. A way to execute applications if they’re not already running, otherwise focus them (A modified version of this script)
  3. A way to map your pinned items to your Win + n shortcut keys (my scripts)

Step 1: Getting DockbarX

If you have ubuntu-tweak on your system, you can find DockbarX in its Application Center. Just put the checkmark, click apply and you’re done.

If you do not have ubuntu-tweak and you’re using Ubuntu 9.10 (Karmic), just execute the following in your terminal:

sudo add-apt-repository ppa:dockbar-main/ppa
sudo apt-get update && sudo apt-get install dockbarx

For older versions of Ubuntu, the DockbarX repository is here. If you’re not sure how to add this repository and install DockbarX, just ask.

If you’re running Gnome, just logout and back in, then right click your panel and add DockbarX to your panel.

If you’re running Xfce, you’ll need to install xfapplet (sudo apt-get install xfce4-xfapplet-plugin). Then right click your panel, add xfapplet, and then select DockbarX.

Now that you have DockbarX running, you can choose to get rid of your taskbar. You can also pin some apps to the taskbar (right click -> pin application) to test if the hotkeys work later. You can also play around with DockbarX prefs and themes to get the right look. Here’s what I ended up with in Xfce:

mytaskbar

Step 2: Get the scripts:

Grab the attached scripts. Create a subdirectory in your home directory called ‘scripts’ and extract all the scripts in there.

Next, we’ll make these scripts executable and place a link to them in the /usr/bin directory so they are easier to execute.

chmod a+x ~/scripts/run_or_focus.py
chmod a+x ~/scripts/*update_hotkeys*.py
sudo ln -s ~/scripts/run_or_focus.py /usr/bin/rof

You’ll need python, gconf and wmctrl to run these scripts. If you’re on xfce, you’ll also need xfquery. To get them:

Gnome: sudo apt-get install python wmctrl python-gconf
Xfce:
sudo apt-get install python wmctrl python-gconf xfconf

To test the scripts to see if they’re working, try entering “rof firefox” on the command line to either run firefox or focus it if its already running.

Setting hotkeys for DockbarX pinned items

First, pin some applications to your taskbar.

Here I’ve given you a couple of options. In your scripts directory, you’ll find autoupdate_hotkeys and update_hotkeys for gnome and xfce. The autoupdate_hotkeys version will keep running in the background and update your hotkeys as soon as you make a change. So if you drag a pinned item around, its hotkey will be updated automatically. If you unpin it, its hotkey will be removed. If you pin a new item, we’ll add a hotkey for it. This is useful because it requires nothing from you other than adding the scripts to your startup applications.So if you prefer this option, just add the autoupdate_hotkeys_(gnome|xfce).py to your startup applications (preferences -> startup applications in gnome and settings -> session and startup in xfce) and you’ll be good to go.

If you prefer not to have an extra app running in the background, you’ll need to run the update_hotkey scripts whenever you change items around in dockbar.

Comments? Problems? Enjoying Ubuntu a little teensy bit more? 🙂