My configuration of xmonad window manager with xmobar and trayer
I’ll write here my configuration of xmonad in order to find it easily in the future. xmonad is a dynamically tiling X11 window manager that is written and configured in Haskell (http://xmonad.org/). I find xmonad really useful on systems with small screens and on laptops to avoid using the touchpad.
Software
- xmonad (0.8) – the window manager
- xmobar (0.9) – a status bar also in haskell
- trayer (1.0) – small app for a systray
- feh (1.3.4) -to set the background image
- gdm, kmix, network-manager, …
How to install stuff
You’ll find more or less all the software needed on the repositories of the distribution of your choice (if you use ubuntu, like me, this should install the window manager apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools).
Configuration
Following the config files of the various softwares:
xmonad – ~/.xmonad/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
, className =? "Vncviewer" --> doFloat
]
main = do
xmproc <- spawnPipe "xmobar"
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 "green" "" . shorten 50
}
, modMask = mod4Mask -- Rebind Mod to the Windows key
} `additionalKeys`
[ ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
, ((0, xK_Print), spawn "scrot")
]
xmobar – ~/.xmobarrc
Config { font = "-misc-fixed-*-*-*-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 85
, commands = [ Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","15","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: %"] 10
, Run Swap [] 10
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run StdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ %cpu% | %memory% * %swap% | %wlan0% | %date%"
}
gdm – /usr/share/xsessions/xmonad.desktop
[Desktop Entry] Encoding=UTF-8 Name=XMonad Comment=Leightweight tiling window manager Exec=xmonad.start Icon=xmonad.png Type=XSession
xmonad.start is a custom script.
xmonad.start – /usr/local/bin/xmonad.start
#!/bin/bash xrdb -merge .Xresources trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 15 --height 12 --transparent true --tint 0x000000 & gnome-screensaver gnome-settings-daemon if [ -x /usr/bin/gnome-power-manager ] ; then sleep 1 gnome-power-manager fi if [ -x /usr/bin/nm-applet ] ; then nm-applet --sm-disable & fi kmix --keepvisibility #feh --bg-scale /mnt/archivio/foto/2008-2009-dublino/2009-04-10-stefano/hapenny-desktop.jpg & exec xmonad
Notes:
- using gnome-settings-daemon (i.e. for multimedia keys) the use of feh for setting the background image is unnecessary.
Screenshots
A screenshot of the desktop without applications (only xmonad and trayer), the background image is the Ha’Penny Bridge, Dublin, by Steve:
now with some apps:


Hey man!
I think you don’t live (or used to live) far from where I do, in Maniago.
Anyhow, I’m fairly new to xmonad and what I basically need is a GTK notification area in order to get rid of the xfce4 panel for the SkyPe notification icon – I don’t really need the icon, a string will do. Do you know of a lightweight software I could use with xmonad which provides that?
Thanksss,
Michele.
Ah, reading better I now see you use “trayer” for that!
I’ll try this config tomorrow.
Thanks,
Michele.
@Michele
You’re right, I (used to) live in Travesio (and in Maniago I attended the liceo) =).
Yes, the “trayer” is quite nice and just does the job.
(Your website http://www.cattlegrind.info/ seems down, is this a temporary problem or maybe a typo in the url?)
mandi mandi,
arjuna
Er ops, it’s really:
http://www.cattlegrid.info/
Mistyped it.
For now I posted about an xmonad+xfce integration which I like enough… but I’m really looking into going more minimal, and minimal, and….
Cheers,
Michele.
It didn’t work for me sadly on arch linux 64. All I got was a weird green background and none of the xmonad key bindings worked. I had to launch a shell to kill xmonad.
@matt
strange, maybe try to read the docs on how to use xmonad http://xmonad.org/tour.html (remember that in my config the Mod key is the Windows button on keyboard)
can be also a copy&paste problem, to be sure the config file is correct try ghci ~/.xmonad/xmonad.hs
you should see something like
$ ghci ~/.xmonad/xmonad.hs GHCi, version 6.8.2: http://www.haskell.org/ghc/
for help
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> :t main
main :: IO ()
Yeah I think there was an issue with xmonad.hs not compiling. I had to strip everything out and am now trying stuff little by little. Maybe it has something to do with the fact that I’m using ghc 6.10?
Now I’m wrestling with how to use trayer. I think I have it docked on the bottom, but I have no idea what it’s doing for me.
Hello man,
Many thanks for the config files.
They were very helpfull.
However, I have a problem.
Despite I use the config files almost identical to yours, there is nowhere an indication of the workspaces.
([1] [2] …) have dissapeared compleatly, and I have no idea why.
As I see from your screenshot I should see something like that.
Any idea?
Hallo again,
After a little while I noticed that I was missing StdinReader.
Very important.
Molto grazie
Thanks for the post. It helped me get up and running quickly which is exactly what I was looking for. You wrote it on my birthday, so I’m going to call it a birthday present
After reading your instructions, I decided to integrate xmonad more fully into my normal Ubuntu environment. Hence, I wrote my own instructions here: http://jjinux.blogspot.com/2009/11/linux-my-xmonad-setup.html. I referenced your instructions in my blog post.
Thanks again!
Trayer doesn’t seem to exist in Karmic repositories.
You can get it here:
http://archive.ubuntu.com/ubuntu/pool/universe/t/trayer/trayer_1.0-2_amd64.deb
For Ubuntu users, when you click on the link it should open in gdebi.
(For 64 bit, there are packages for other arches in http://archive.ubuntu.com/ubuntu/pool/universe/t/trayer/ )
Thanks for writing this up. It’s great to have a How To on creating a setup in between “full on gnome with xmonad instead of metacity” and “totally minimal just xmonad”. If people get xsession-errors about xmonad not providing window manager, or it otherwise doesn’t automatically start on login… likely the applications/xmonad.desktop file is missing. Can use:
$ cat /usr/share/applications/xmonad.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Xmonad
Exec=xmonad
NoDisplay=true
X-GNOME-WMName=Xmonad
X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Provides=windowmanager
X-GNOME-Autostart-Notify=false
[...] configuration above is a mix and match from these four pages and my own [...]
Thanks for posting this! I’m running Ubuntu 10.4 LL & am just getting started with xmonad. This was a big help.
Just to let you know, I had trouble with your .xmobarrc and your xmonad.start, but I figured it out with some tinkering.
For .xmobarrc, I just modified the .xmobarrc-example in my docs. Perhaps I’m using a different version of xmobar? (0.9.2)
For xmonad.start I had to append an & to gnome-power-manager and the nm-applet lines.
Not completely sure why I had to do those things, but everything works find now.