About "converting" :
As xmonad.hs is just haskell source code that is compiled into "your" xmonad, there isn't really a "format" and there are many ways to write the same thing.
If you mean how to convert main
from using =<< operator to do notation :
main = xmonad =<< statusBar myBar myPP statusbarToggleKey myConfig
Here you are using two functions :
the statusBar function that takes four arguments and returns
IO (XConfig (ModifiedLayout AvoidStruts l)
. So basically, using what you passed to itstatusBar
creates the corresponding XConfig and returns it wrapped in the IO monad.the xmonad function taking an XConfig and returning IO()
The =<< combines the two : takes the XConfig returned by statusBar
out of the IO monad and pass it to xmonad
.
The equivalent in do notation is :
main = do
config <- statusBar myBar myPP statusbarToggleKey myConfig
xmonad config
But once you understand what the monads operators do, they can look more elegant than do notation.
Using dzen :
If you want to keep using the statusBar
function, you just need to change the arguments you are passing to it.
-- the command line to launch the status bar
myBar = "dzen2 -y -1" --that's for dzen at the bottom of the screen
-- the PP
myPP = defaultPP
Key bindings :
You can see the type of keys
in XConfig definition. It's a function taking an XConfig and returning a map.
Here is an example of a "pretty" way to write it, using the fromList
function from Data.Map
:
import qualified Data.Map as M
myKeys conf@(XConfig {modMask = modm}) = M.fromList $
[
((modm, xK_c), kill),
((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
]
And then if you want to use the keys defined in defaultConfig in addition to yours, you can use <+>
:
myConfig = defaultConfig
{
...
, keys = myKeys <+> keys defaultConfig
}