Configuring XMonad
2014-04-25 18:00
Configuring XMonad
I have been setting up XMonad on my Debian box, partially because I am kinda hooked on Haskell right now, and so far it has been a prety fun adventure. Just wish to share some thoughts here.
Getting XMonad
Being on Debian has its perks, a aptitude install xmonad
simply works, else just head to XMonad to get the suitable
package.
Running XMonad
I’m using startx
to run XMonad, so all I have to do is
to edit ~/.xinitrc
, and add the line
exec xmonad
If you’re using a display manager such as KDM, GDM, slim, lightdm
etc, there’s probably a way to select which which session you want to
run, or you can edit your ~/.xsession
file. You can
probably get more information here.
Configuring XMonad
This is the really fun part. I’ve tried finding good configurations I can immediately copy and use, and actually found this, but when it comes to configuring your window manager, everyone is heavily opiniated. After spending some time on it, I found that the best way to configure XMonad is to do it in small steps.
I think the most efficient way to figure things out is to learn the
defaults first, by looking at the tour from the official pages. This will
give you a feel of how to do things. The most important takeaway is: -
Mod + Shift + Enter
fires up a terminal, and by default
Mod
is Left-Alt
- Mod-Q
restarts
xmonad, this allows you to see changes you have made to the config file
quickly - ~/.xmonad/xmonad.hs
is the default configuration
file
Then move on to the actual configuration, and a gentleman has wrote a extremely easy to follow step-wise [guide](www.haskell.org/haskellwiki/Xmonad/Config_archive/John_Goerzen’s_Configuration) on configuring XMonad. Follow this guide to the end, and you should have a simple yet efficient XMonad up and running.
Caveats
I faced one small issue, which was the loading of xmobar configuration file. Particularly the line
<- spawnPipe "xmobar /home/ngzhian/.xmonad/.xmobarrc" xmproc
For some reason xmobar didn’t manage to load the file that I passed
in. I solved it by not passing in a filename, and just creating the
config file at the default location, which is ~/.xmobarrc
.
So that line simply became
<- spawnPipe "xmobar" xmproc
I’ll write about xmobar soon, it’s fun to configure it as well, but for now here’s what I have
-- /home/ngzhian/.xmonad/xmonad.sh
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
= do
main <- spawnPipe "xmobar"
xmproc $ defaultConfig
xmonad = manageDocks <+> myManageHook <+> manageHook defaultConfig
{ manageHook = avoidStruts $ layoutHook defaultConfig
, layoutHook = dynamicLogWithPP xmobarPP
, logHook = hPutStrLn xmproc
{ ppOutput = xmobarColor "#021030" "" . shorten 100
, ppTitle
}= mod4Mask -- Rebind Mod to Windows key
, modMask = myTerminal -- set terminal
, terminal `additionalKeys`
} .|. shiftMask, xK_l), spawn "xscreensaver-command -lock")
[ ((mod4Mask "sleep 0.2; scrot -s")
, ((controlMask, xK_Print), spawn 0, xK_Print), spawn "scrot")
, ((
]
-- Preferred terminal
= "/usr/bin/urxvt"
myTerminal
-- Managing hooks when windows are created
= composeAll
myManageHook =? "Gimp" --> doFloat
[ className ]