Difference between revisions of "Xmonad/General xmonad.hs config tips"

From HaskellWiki
Jump to navigation Jump to search
m (add a link to the X11 lib docs showing key identifiers)
Line 35: Line 35:
 
mykeys (XConfig {modMask = modm}) = M.fromList $
 
mykeys (XConfig {modMask = modm}) = M.fromList $
 
[ ((modm , xK_x), spawn "xlock") ]
 
[ ((modm , xK_x), spawn "xlock") ]
  +
  +
For a list of the identifiers used for various keys, see
  +
[http://hackage.haskell.org/packages/archive/X11/1.4.1/doc/html/Graphics-X11-Types.html].
   
 
== Sharing a configuration across different hosts ==
 
== Sharing a configuration across different hosts ==

Revision as of 00:53, 31 January 2008

This site is for general tips for configuring xmonad.hs, for example "How to make window X float by default" and others. If you can't find what you're searching for, you may want to look at the Config archive.

Please add what you found useful in your xmonad.hs and course improving existing tips or adding alternatives is highly appreciated!

Making window float by default, or send it to specific workspace

This example sends Firefox to workspace "web" by default, makes Gajim float and sends it to webspace "jabber" and Xmessage is floating by default, too.

  main = xmonad $ defaultConfig
  {
  ....
  , manageHook    = manageHook defaultConfig <+> myManageHook
  ...
  }
  myManageHook :: ManageHook
  myManageHook = composeAll . concat $
      [ [ className =? c --> doFloat | c <- myFloats ]
      , [ className =? "Firefox-bin" --> doF (W.shift "web" ) ]
      , [ className =? "Gajim.py" --> doF (W.shift "jabber" ) ] ]
      where myFloats = ["Gajim.py", "Xmessage"]

Adding your own keybindings

This adds Mod-x keybinding for running xlock.

  import qualified Data.Map as M
  ....
  main = xmonad $ defaultConfig
  {
  ....
  , keys          = \c -> mykeys c `M.union` keys defaultConfig c }
  ....
  }
  where
      mykeys (XConfig {modMask = modm}) = M.fromList $
           [ ((modm , xK_x), spawn "xlock") ]

For a list of the identifiers used for various keys, see [1].

Sharing a configuration across different hosts

It is possible to have different parts of the configuration file vary from one host to another, without needing a different config file for each host. Here is an example from my configuration file:

   import System.Posix.Unistd
   .
   .
   .
   main = do
       host <- fmap nodeName getSystemID
       xmonad $ defaultConfig
         { terminal           = "rxvt"
         , modMask            = (if host == "janice" then
                                   mod1Mask .|. controlMask
                                 else
                                   mod4Mask)}