Wednesday, November 18, 2009

xmonad settings

One thing that I did like about using gnome was that for most things, it was very discoverable. You click a few menus, try this and that. But with something like xmonad, it's much more configurable for sure but you certainly have to know your way around. So after seaching the internet, I've finally had a setup which I pretty much like. Here it is for future reference. For ~/.xmnonad/xmonad.hs:

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.

Sunday, November 15, 2009

argouml in xmonad

Recently a small window manager war broke out at the #archlinux irc channel. Not much to say about it because it's been done dozens of times already, but it did got me interested in trying out a tiling wm again. I've tried xmonad before and liked it quite a bit back then so I thought I'd give it another go. And sure enough I LOVE it.. :P Not having to touch the mouse (or the touchpad which is even worse) at all is a great feeling. You just want to go faster and faster. Then I fired up firefox and lo and behold, I have to use the mouse again. That's a cannot. So I installed the vimperator plugin. Now I can navigate and use firefox just like using my favourite editor.. :D

But of course that's just the beginning, I had to look for replacement for a lot of other software I normally use too. So now:
1. pidgin -> finch (ym client)
2. xchat-gnome -> weechat-curses (irc client)
3. evolution -> alpine (mail client)
4. exaile -> herrie (mp3 player)
5. nautilus -> mc (file manager)

Then I faced another problem. When I started out argouml all it showed was a grey window. Nothing, nada. No display whatsoever. I really thought I had to go back to gnome already. Then I did a bit of googling and finally found this at the awesome wm wiki (another tiling wm). Basically the problem is with jvm in a non-reparenting window manager. So to fix it, we can emulate another window manager which jvm thinks is a reparenting window manager. Just install 'wmname' (yes.. that is.. pacman -S wmname) and run:

$ wmname LG3D

And walah.. argouml running once again. Even though you close the terminal and start just argouml, it'll work. So far I'm loving this slimming down of my desktop, now if only I could start slimming down my own body.. :P

Haiya ala Solah