import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
myManageHook = composeAll
[ className =? "Gimp" --> doFloat
]
main = do
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig
{ terminal = "urxvt"
, modMask = mod4Mask
, borderWidth = 3
, manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP $ xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
} `additionalKeys`
[ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock")
, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
, ((0, xK_Print), spawn "scrot")
]
That will, amongs other things, make sure that gimp does not tile but stay float, it will start up xmobar, set my default terminal to urxvt, use the win key for meta (better than using alt since alt is used by most programs), logHook to create an output to be used by xmobar, make sure xmobar stay visible eventhough the screen is full of other programs, set win+shift+z will lock the screen with xscreensaver.
Okay, next is setting for xmobar. This is my ~/.xmobarrc:
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 90
, lowerOnStart = True
, commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run StdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ %cpu% | %memory% | %wlan0% | %eth0% * <fc=#ee9a00>%date%</fc> @ %hostname%"
}
Ok. This will create the xmobar on the top 90% of the screen. Another 10% we want to reserve for trayer for our programs that require a system tray (eg Pidgin) if we use any. It display a few useful info, but I think on of the most useful ones is the date, and also the output from xmonad which would show what workspace you are currently on (very very useful) and also the title of the window you're currently viewing (not so useful but still nice to have).
Next is I want my urxvt to look nice. So here is the settings for my ~/.Xresources:
URxvt*background: #242424
URxvt*cutchars: BACKSLASH '"'&()*,;<=>?@[]{|}
URxvt*colorUL: #86a2be
URxvt*foreground: #ffffff
URxvt*geometry: 80x25
URxvt.cursorColor: #86a2be
URxvt*internalBorder: 0
URxvt*jumpScroll: true
URxvt*loginShell: true
URxvt*perl-ext-common: default,matcher,searchable-scrollback
URxvt*pointerBlank: true
URxvt*saveLines: 4000
URxvt*secondaryScroll: true
URxvt*scrollBar: false
URxvt*scrollTtyKeypress: true
URxvt*scrollWithBuffer: true
URxvt*termName: rxvt-unicode
URxvt*underlineColor: #86a2be
URxvt*urlLauncher: /usr/bin/firefox
URxvt*color0: #242424
URxvt*color1: #bf7979
URxvt*color2: #97b26b
URxvt*color3: #cdcda1
URxvt*color4: #86a2be
URxvt*color5: #d9b798
URxvt*color6: #a1b5cd
URxvt*color7: #ffffff
URxvt*color8: #cdb5cd
URxvt*color9: #f4a45f
URxvt*color10: #c5f779
URxvt*color11: #ffffaf
URxvt*color12: #98afd9
URxvt*color13: #d7d998
URxvt*color14: #a1b5cd
URxvt*color15: #dedede
URxvt*font: xft:Terminus:pixelsize=15
I found this in a Ubuntu forum. I changed the font to Terminus with size 15 though. Much nicer on the eyes not to have to squint so much trying to read a small font. Then finally to put it all together, I have this in ~/.xinitrc:
xsetroot -cursor_name left_ptr
if xrandr -q | grep -q "VGA1 connected"; then
xrandr --output VGA1 --mode 1024x768 --left-of LVDS1 --output LVDS1 --mode 1366x768
fi
trayer --edge top --align right --transparent true --width 10 --tint 0x191970 --height 12 --expand true --widthtype request --heighttype request --SetDockType true --SetPartialStrut true &
xscreensaver -no-splash &
xrdb -merge ~/.Xresources
exec ck-launch-session xmonad
Amongst other things it detect whether I have an external monitor connected and automatically make xrandr extend to that if there is one. It sets up trayer (using the 10% we preserved earlier). It starts up xscreensaver. It actually load the .Xresources (normally this would be done by the gdm, but since I'm not using the gdm so this is how you load it and finally it launches xmonad. Phew.. That's basically it. As long as this blog post hold up, I can reformat my machine and recover the settings which I pretty much like for xmobar and gang.
Disclaimer: None of these settings are my original. Some of them I've got from xmonad and xmobar faq's and tutorials, others I've got from other various pages on the net.