Import the module into your ~/.xmonad/xmonad.hs:
import XMonad.Actions.WindowGo
and define appropriate key bindings:
, ((modMask x .|. shiftMask, xK_g), raise (className =? "Firefox"))
, ((modMask x .|. shiftMask, xK_b), runOrRaise "firefox" (className =? "Firefox"))
(Note that Firefox v3 and up have a class-name of Firefox and Navigator;
lower versions use other classnames such as Firefox-bin
For detailed instructions on editing your key bindings, see
XMonad.Doc.Extending#Editing_key_bindings.
|
raiseMaybe queries all Windows based on a boolean provided by the
user. Currently, there are three such useful booleans defined in
XMonad.ManageHook: title, resource, className. Each one tests based pretty
much as you would think. ManageHook also defines several operators, the most
useful of which is (=?). So a useful test might be finding a Window whose
class is Firefox. Firefox declares the class Firefox, so you'd want to
pass in a boolean like '(className =? Firefox)'.
If the boolean returns True on one or more windows, then XMonad will quickly
make visible the first result. If no Window meets the criteria, then the
first argument comes into play.
The first argument is an arbitrary IO function which will be executed if the
tests fail. This is what enables runOrRaise to use raiseMaybe: it simply runs
the desired program if it isn't found. But you don't have to do that. Maybe
you want to do nothing if the search fails (the definition of raise), or
maybe you want to write to a log file, or call some prompt function, or
something crazy like that. This hook gives you that flexibility. You can do
some cute things with this hook. Suppose you want to do the same thing for
Mutt which you just did for Firefox - but Mutt runs inside a terminal window?
No problem: you search for a terminal window calling itself mutt, and if
there isn't you run a terminal with a command to run Mutt! Here's an example
(borrowing XMonad.Utils.Run's runInTerm):
, ((modm, xK_m), raiseMaybe (runInTerm "-title mutt" "mutt") (title =? "mutt"))
|