Black God

How to get a productive desktop based on xmonad and xmobar?

I am very poor in handling multiple windows in a desktop. And also my logic in getting a useful windows layout is pathetically low. Linux allows us to experiment with different window managers. So I experimented different window managers and settled with xmonad. This is a tiling window manager – i.e., windows are not overlapped, instead they are tiled over the desktop. All your window management is automated. Another major advantage of keyboard oriented design makes it a obvious choice for me. It is light weight, no window decoration, no other bells and whistles. There is a status bar application called xmobar, native to xmonad.

My hardware is Sony VAIO laptop VGN-CS15GN/B. I did a base Debian (Testing) – Network based installation to get a base system. Here I summarize the ways to get a productive desktop based on xmonad and xmobar. And also all important configuration files are shared.

GUI system: On top of base system, we need to install X windows system, Audio support (alsa) as shown below.

# apt-get install xserver-xorg xinit alsa-base alsa-utils alsa-tools

If you have HP Printer, you may need to install the following to get HP printer working.

# apt-get install hplip python-qt4

Desktop: xmonad window manager, xmobar status bar and other assoicated tools can be installed with following command. trayer is a system tray application, parcellite is a clipboard, dmenu is a launcher, lxappearnce is meant for GTK application theme configurtion. Apart from these we install widely used fonts.

# apt-get install xmonad consolekit xmobar trayer parcellite dmenu lxappearance ttf-liberation ttf-mscorefonts-installer

X Server configuration (~/.Xdefaults):



Xft.dpi: 96
Xft.lcdfilter: lcddefault
Xft.antialias: true
Xft.hinting:true
Xft.hintstyle: hintfull
Xft.rgba: rgb
*customization: -color


X Login settings (~/.xinitrc):



# system tray
trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --widthtype percent --width 5 --transparent true --tint 0x000000 --height 12 &
# screensaver
xscreensaver -no-splash &
# set the cursoe as pointer, otherwise X will appear as cursor
xsetroot -cursor_name left_ptr
# start clipboard manager without icon
parcellite &
# let me go ahead with pre starting some of the apps
xterm &
xterm &
google-chrome &
# time to start, the master - the window manager xmonad
exec ck-launch-session xmonad


Applications: Here is my selection of applications for my usage. You may go ahead installing your favourites. My selection criteria is light weight less popular tools along with VLC and VI editors. vim-gtk version installed esepecially for its X clipboard capability.

# apt-get install file-roller vlc esperanza evince vim-gtk mirage pcmanfm scrot

Google Chrome can be installed from here.

Theme downloads:

GTK Theme: Murrine : http://gnome-look.org/CONTENT/content-files/79842-themes.zip

Icon Theme: Faenza : http://tiheum.deviantart.com/art/Faenza-Icons-173323228

Xmonad configuration (~/.xmonad/xmonad.hs):


import XMonad

import XMonad.Hooks.DynamicLog

import XMonad.Hooks.ManageDocks

import XMonad.Util.Run(spawnPipe)

import XMonad.Util.EZConfig(additionalKeys)

import XMonad.Layout.NoBorders

import System.IO

myManageHook = composeAll

[ className =? "Gimp" --> doFloat

, className =? "Vncviewer" --> doFloat

]

main = do

xmproc <- spawnPipe "/usr/bin/xmobar /home/blackgod/.xmobarrc"

xmonad $ defaultConfig

{ manageHook = manageDocks <+> myManageHook -- make sure to include myManageHook definition from above

<+> manageHook defaultConfig

, layoutHook = avoidStruts $ layoutHook defaultConfig

, logHook = dynamicLogWithPP xmobarPP

{ ppOutput = hPutStrLn xmproc

, ppTitle = xmobarColor "grey" "" . shorten 50

}

, modMask = mod4Mask -- Rebind Mod to the Windows key

} `additionalKeys`

[ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock")

, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")

, ((0, xK_Print), spawn "scrot")

]


In the above file, set your .xmobarrc file properly. This is the configuration file for xmobar.

xmobar configuration (~/.xmobarrc):


Config { font = "-*-fixed-*-*-*-*-12-*-*-*-*-*-*-*"

, bgColor = "black"

, fgColor = "grey"

, position = TopW L 95

, commands = [ Run Weather "VOMM" ["-t"," C","-L","64","-H","77","--normal","green","--high","red","--low","lightblue"] 36000

, Run MultiCpu ["-t","CPU: % %", "-L", "40", "-H", "60", "-l", "lightblue", "-n", "white", "-h", "red"] 10

, Run CpuFreq ["-t", " ", "-L", "0", "-H", "2", "-l", "lightblue", "-n","white", "-h", "red"] 50

, Run Com "/home/blackgod/system/getcoretemp.sh" [] "coreTemp" 10

--, Run CoreTemp ["-t", "C C", "-L", "40", "-H", "60", "-l", "lightblue", "-n", "white", "-h", "red"] 50

, Run Memory ["-t","Mem: %"] 10

, Run Swap [] 10

, Run Wireless "wlan0" ["-t","wlan0: %","-L","0","-H","32","--normal","green","--high","red"] 10

, Run Battery ["-t","Batt: %","-L","25","-H","75","--low","#FF0000","--normal","#F9FF00","--high","#00FF00"] 600

, Run Com "/home/blackgod/system/getvolume.sh" [] "myVolume" 10

, Run Date "%a %b %_d %I:%M %p" "date" 10

, Run StdinReader

]

, sepChar = "%"

, alignSep = "}{"

, template = "%StdinReader% }{ %multicpu% %cpufreq% %coreTemp% %memory% %swap% %wlan0wi% %battery% Vol: %myVolume% Weather: %VOMM% %date%"

}


In the above configuration file, VOMM is my city’s (Chennai, India) weather station code; you may replace it with your’s from here. CPU Core Temperature display has been commented out (–), it has been replaced with getcoretemp.sh script, I have written since my kernel 3.0.0 breaks the xmobar’s default CoreTemp script. And also I was not able to get default Volume status working, so I have replaced with getvolume.sh script, which I obtained from a nice guy online. You may find below these scripts.

getcoretemp.sh:



#!/bin/bash
temp1=`cat /sys/devices/platform/coretemp.0/temp2_input`
temp2=`cat /sys/devices/platform/coretemp.0/temp3_input`
echo `expr $temp1 / 1000`C `expr $temp2 / 1000`C


getvolume.sh



#!/bin/bash
str=`amixer sget Master,0`
str1=${str#Simple*\[}
v1=${str1%%]*]}
il=`expr index "$str1" [`
o="off"
mutel=''
if [ ${str1:$il:3} == $o ]; then mutel='M'; fi
s=${str1:0:1}
str2=${str1#${str1:0:1}*\[}
str1=$str2
str2=${str1#${str1:0:1}*\[}
ir=`expr index "$str2" [`
muter=''
if [ ${str2:$il:3} = $o ]; then muter='M'; fi
v2=${str2%%]*]}
v=${v1}\ $mutel\ ${v2}\ $muter
echo $v


3 comments for “How to get a productive desktop based on xmonad and xmobar?

  1. NoSpies
    March 16, 2012 at 7:36 pm

    If you support ideology of Hitler, slavery, Big Brother and those sorts of.. um.. lifestyles… I can see why you’d promote Google-Chrome. Otherwise, there is always freedom-promoting SRWare IRON browser which is Chrome source code stripped of tracking, spying, reporting Google parasite. Thanks.

    • Mr Erdk
      June 25, 2012 at 12:08 pm

      And where exactly is GNU/Linux version of SRWare IRON? Oh, it didn’t exist…

  2. Valadil
    January 1, 2012 at 11:07 pm

    Instead of polling the volume every 10 seconds, try this script which outputs whenever the volume changes. https://github.com/sagotsky/.dotfiles/blob/master/scripts/notify-volume.sh

Leave a Reply

Your email address will not be published. Required fields are marked *