Search This Blog

Friday, 4 January 2013

Going Minimalist with xmonad

You may have read in my ramblings how I am one of these people who actually likes Unity on Ubuntu and find it lets me get more stuff done. Well, I still think that, but in the last few days I've been tempted into looking elsewhere for some thing different...

One of the guys I work with runs Arch Linux and uses xmonad as his window manager. No, I'm not going down the painful path of Arch, but I have decided to take a look at xmonad as an alternative WM on my (Ubuntu running) work laptop. (Thanks Michal....)

Talk about a learning curve! It is very different to Unity in that it is minimalist, has no eye candy and uses the keyboard much more than the mouse. But what a fast and responsive way of working it has proved to be!

Installation was a breeze

sudo apt-get install xmonad

and following the 2 links here and here made the initial config reasonably easy. Here are my xmonad.hs and .xmobarrc config files:


import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
myWorkspaces = ["1:terminal","2:web","3:XenDesktop","4:four","5:five","6:six","7:seven","8:eight","9:nine"]
main = do
    xmproc <- spawnPipe "/usr/bin/xmobar /home/stefan/.xmobarrc"
    xmonad $ defaultConfig
        { manageHook = manageDocks <+> manageHook defaultConfig
        , workspaces = myWorkspaces
        , layoutHook = avoidStruts  $  layoutHook defaultConfig
        , logHook = dynamicLogWithPP xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50


Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
       , bgColor = "black"
       , fgColor = "grey"
       , position = TopW L 90
       , lowerOnStart = True
       , commands = [ Run Network "wlan0" ["-t","Wireless: Rx<rx>|Tx<tx>","-S","True"] 10
                    , Run MultiCpu ["-t","Cpu: <autototal>","-L","30","-H","60","-h","#FFB6B0","-l","#CEFFAC","-n","#FFFFCC","-w","3"] 10
                    , Run Memory ["-t","Mem: <usedratio>%"] 10
                    , Run Swap [] 10
                    , Run Date "%a %b %_d %l:%M" "date" 10
                    , Run StdinReader
   , Run Network "eth0" ["-t","Wired: Rx<rx>|Tx<tx>","-S","True"] 10
       , sepChar = "%"
       , alignSep = "}{"
       , template = "%StdinReader% }{ %multicpu% | %memory% * %swap% | %eth0% | %wlan0% | <fc=#ee9a00>%date%</fc> "

These 2 files will provide a reasonable starting point for anyone wanting to try this out.

I have 2 specific comments though:

Firstly, I'd forgotten how much I love tinkering with Linux. Using it every day to put in a full day's work is good, especially compared to the Windows alternative, but it's really nice to tinker with a new setup and alter it to do exactly what you want. In my case it involved writing a small script to start trayer, a small tray utility to display applets like those in the system tray, and some applets which I use a lot like the Network Manager and Bluetooth applets.


# Script to start trayer and required applets
trayer --edge top --align right --SetDockType true --SetPartialStrut true  --expand true --width 10 --transparent true --tint 0x191970 --height 13 &
sleep 3
nm-applet --sm-disable &
sleep 3
bluetooth-applet &
sleep 3
dropbox start
exit 0

This script is called from a small wrapper script which sets my display options to my work configuration, with an external monitor to the right of my laptop.


xrandr --output LVDS1 --mode 1600x900 --output VGA1 --mode 1680x1050 --right-of LVDS1
exit 0

I also had to tweak some other settings to get xmobar to display the data I wanted to see in the status bar. Ok, this is all done automatically in a full desktop WM like Unity, but I enjoyed tinkering, tweaking and ending up with a desktop that works for me.

Secondly, it is amazing just how much my work is streamlined using a tiling window manager and using keystrokes to flick between desktops, monitors and open windows. It is difficult to imagine the difference made by not moving my hands from keyboard to the mouse and back as much. I still use the mouse in browser windows etc. but for the majority of my work I can get away with only using my keyboard.

I guess in short, it has once again been brought home to me how versatile Linux is, and how easy it is to customise to your own requirements. If you don't like one Desktop Environment, use another, just be comfortable with whatever you use.

I'll be using Unity and xmonad interchangeably from now on...

No comments:

Post a Comment