|Scripts quick access edit this|
Restore focus to last "interesting" window when switching to an workspace.
This script solves a minor annoyance that I'm having for ages; I'm no Lisp hacker, but I finally decided to fix it.
In my setup, I'm using Sawfish as a WM for Gnome (so I'm using Gnome panels, Nautilus for desktop, Gnome's workspace switcher, etc.). The problem was that every time I switch an workspace with the mouse (click in the workspace switcher), the panel window gets focused and Sawfish remembers that the last window in the workspace that I'm leaving is Gnome Panel. When I later return to that workspace, instead of focusing some window, it focuses the Gnome Panel.
This script installs some hooks that will maintain focus on interesting windows (i.e. the last window used which is not Panel or Desktop).
In order to solve this problem previously, I had some rules in "matched windows" that forbidden focus at all on Panel or Desktop windows, but that was bad too because I couldn't, for example, rename a file on my Desktop by just clicking on it and hitting F2 (since the Desktop never would receive focus).
Save it in ~/.sawfish/lisp/ and add (require 'restore-focus) in your ~/.sawfishrc
You can edit the script and change the definition of *avoid-focus* regexp.