skip to main bit
a man slumped on his desk, from 'The Sleep of Reason Produces
      Monsters'

Oblomovka

Currently:

Archive for July 29th, 2008

2008-07-29

rag and bone scripts: switchto

So I feel a bit bad because I have two half-written long thoughtful posts, but this evening was games night at the EFF’s hollowed-out mountain headquarters, and after a bit too much Settlers of Cataan, beer, Rock Band, and beer, I strangely cannot be bothered to finish those entries. I will just repeat for the record that you have not seen rules lawyering until you have seen EFF’s litigation team play AD&D. I still admire Quinn for daring to DM them.

Anyway, instead, let me fob you off with a couple of tiny hacks I use pretty frequently on my Linux desktop.

They all gank their usefulness from wmctrl, which is a fantastic command line utility for almost any Linux desktop, and lets you control windows and focus from the command line. You can install it from that webpage, or just do apt-get install wmctrl on Debian/Ubuntu.

I save the above script as ‘switchto’, and use it in GNOME’s keyboard shortcuts like this:

That should set some options in the standard GNOME editor to run
switchto "Mozilla Firefox" "firefox"
whenever you hit Alt-F. It works with metacity and compiz, which is probably what you’re running with GNOME. Other desktops will have other ways to create keyboard shortcuts — I seem to remember that KDE’s one rocks.

Now, whenever I hit Alt-F on my keyboard, my desktop will switch focus to the first window it finds with “Mozilla Firefox” in its name. If it can’t find one (ie I’m not yet running Firefox), it starts it up for me. One key press gives me a Firefox window, either way. Here’s another one:

This is the poor man’s QuickSilver — it pops up a box, and switches your focus to a window that matches the text you type into it. It needs a program called Zenity which comes by default on most GNOME desktops.

Actually, I don’t actually use the second of those that much, but I do have a bunch of scripts like the first, setting up command keys to always switch to certain programs like the Terminal (try switchto "termi"), or IRC or Kontact. Your fingers quickly learn the motion, and finding your key applications even in a mass of desktops becomes instinctive.

I’ve always felt that that was the real power of QuickSilver as a window finder — Alt-Tab never lets you learn a consistent muscle memory to switch to a particular program, so you’re constantly derailing your thought by peering at icons to navigate around. I’d also encourage you to play around with wmctrl on the command line — you may be able to think of other desktop tricks that you can turn into simple keypresses.

                                                                                                                                                                                                                                                                                                           

petit disclaimer:
My employer has enough opinions of its own, without having to have mine too.