Last Updated: February 25, 2016
·
1.996K
· kunday

Barebones XMonad config for Ubuntu

http://www.kunday.com/post/35700432761/barebones-xmonad-config-for-ubuntu

After countless hours of dabbling with Xmonad, a few really weird bugs, I got Xmonad to work nicely in Ubuntu 12.04 LTS. If you haven’t used/heard of Xmonad before you should check out Xmonad. It’s a simple and beautiful tiling manager written in Haskell and is configured in Haskell. I hope this post helps someone who gave it a go but backed of due to some of the weird issues relating to window focus in Java apps.

Why

Kickass multi-monitor support (xinerama) with per screen workspaces.
Simple, minimalistic and fast.
Kickass WM layouts that you can configure using Haskell.
Amazing keyboard shortcuts to re-align windows and navigate seamlessly.
Known Issues

Xmonad has some window focussing issues when it comes to Java apps (hack is available which does not work on JDK7)
Doesn’t work well with Unity 3d, so you might have to switch to Unity 2d. Alternatively if you are using classic gnome-shell, it should work well.
How to get it

If you are ubuntu you can use the traditional package manager aka apt-get to install.

sudo apt-get install xmonad
You should also get some application launcher(Unity dash works, but there are some performance issues). I use dmenu, it’s simplistic and works

sudo apt-get install dmenu
Gnome Session Config

Default install of Xmonad in Ubuntu 12.04 LTS adds the necessary session for Xmonad to work with Gnome with the exception of Default-window manager and DefaultProvider-panel. You can add them by editing the /usr/share/gnome-session/sessions/xmonad.session. You add them to session config which should look something like this.

[GNOME Session]
Name=Xmonad Unity-2D Desktop
RequiredComponents=gnome-settings-daemon;
RequiredProviders=windowmanager;panel;
DefaultProvider-windowmanager=xmonad; #this would have been missing
DefaultProvider-panel=unity-2d-panel; #this would have been missing
Issue with Intellij IDEA:

There is a known issue with XMonad not being able to interact with the GUI components when running under JAVA 7, so simplest would be to run under JAVA 6 and use ICCCMFocus#setWMName “LG3D” to ensure Idea to gain focus and play nicely with Xmonad(It’s included as part of the minimalistic xmonad config.)

Minimalistic Xmonad config

import XMonad
import XMonad.Util.Run
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ICCCMFocus
import XMonad.Config.Gnome
import XMonad.Hooks.SetWMName
import XMonad.Actions.DynamicWorkspaces
myManageHook = composeAll (
[ className =? "Unity-2d-panel" --> doIgnore
, className =? "Unity-2d-launcher" --> doFloat
, className =? "gnome-do" --> doFloat
])
main =
xmonad $ gnomeConfig { modMask = mod4Mask
, startupHook = setWMName "LG3D"
, manageHook = manageDocks <+> myManageHook <+> manageHook gnomeConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = takeTopFocus
} additionalKeys [ ((mod4Mask, xKd), spawn "dmenurun -b")
]
XMonad Keymap cheat sheet

A vim style cheat sheet for Xmonad is available here.

Using OSX ? Brian McKenna (ex - Atlassian) seems to have patched Xmonad to work nicely under OSX.