Xmonad/Using xmonad in Unity 2D

From HaskellWiki

XMonad

Introduction

There are enough differences between the Gnome 3 and Gnome 2 panel that may cause you to look for something else. This guide will help you setup XMonad to be used with Unity 2D.

Unity 2D is different from Unity 3D in a few significant ways: Unity 2D comprises a set of programs (panel, launcher, etc) and allows you to choose which window manager you want to use. On the other hand, Unity 3D is a Compiz plugin, so it can be seen as a window manager (like Gnome Shell).

This guide assumes you will run Unity 2D using the Gnome 3 libraries.

Preparation

Install Unity 2D:

% sudo apt-get install unity-2d-panel

Create the following files:

# /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=true


# /usr/share/gnome-session/sessions/xmonad.session
[GNOME Session]
Name=Xmonad Unity-2D Desktop
RequiredComponents=gnome-settings-daemon;
RequiredProviders=windowmanager;panel;
DefaultProvider-windowmanager=xmonad
DefaultProvider-panel=unity-2d-panel


# /usr/share/xsessions/xmonad-gnome-session.desktop
[Desktop Entry]
Name=Xmonad GNOME
Comment=Tiling window manager
TryExec=/usr/bin/gnome-session
Exec=gnome-session --session=xmonad
Type=XSession

XMonad Setup

First, configure XMonad as you would for it to be used in Gnome. Next you need to make the following changes to your xmonad.hs:

Add the following to your manage hook:

myManageHook = composeAll [
  -- other hooks,
  , className =? "Unity-2d-panel"    --> doIgnore
  , className =? "Unity-2d-launcher" --> doIgnore
  -- more hooks

The Unity 2d panel declares 2 different window types and that seems to be confusing XMonad, so you'll have to explicitely add a gap at the top:

import XMonad.Layout.Gaps

myLayouts = gaps [(U, 24)] $
  -- your other layout configuration

Now you should be ready to login. Make sure you choose the XMonad GNOME session in GDM.

Unity 2D setup

Unity 2D is still using GConf for its configuration, so using GConf Editor, look under desktop/gnome/unity-2d/launcher to see how you can tweak the launcher behavior.