[xmonad] Trying to code jump-or-execute
dons at galois.com
Mon Feb 4 13:11:40 EST 2008
> 2008/1/30 Joseph Garvin <k04jg02 at gmail.com>:
> > I'm a former sawfish user, and I used to have this really awesome keyboard
> > shortcut called "jump-or-exec". I would press for example Super+F, and if
> > Firefox was not running, it would be executed, and if it was already
> > running, then it would be given focus. I had similar shortcuts for emacs,
> > terminals, etc.
> > I'm a bit of a haskell newb -- I can tell that I can simply use 'spawn' to
> > launch a process, and if I had a list of current windows I would know how to
> > iterate through them and find out whether one currently exists, but I don't
> > know how to get such a list. Ideally I'd like to be able to match against
> > window title or class. Is there a way to do this with xmonad?
> A bit of a followup: With Spencer's help, I just 'darcs sent' a patch
> which adds a module - XMonad.Actions.WindowGo - to XMonadContrib. What
> would interest you is the 'runOrRaise' function in it (I come from a
> Ratpoison/StumpWM background, not Sawfish), which does basically what
> you want.
> I right now have in my xmonad.hs's keybindings the line:
> > , ((modm, xK_a ), runOrRaise "firefox" (className =? "Firefox-bin"))
> This does as you would expect, it matches any window with a class of
> Firefox-bin, jumping to it; or failing that, it executes through spawn
> In my limited testing, it seems to work fine. (The module also has two
> other functions in case you don't want to do anything on failure, or
> you want to do something else besides spawn.) I hope it works well for
> you too!
Let's keep the new ideas rolling.
Anyone else got some dream extension/UI ideas?
More information about the xmonad