Xmonad/Using xmonad in Gnome

From HaskellWiki
< Xmonad
Revision as of 20:53, 22 January 2008 by Jevin (talk | contribs) (Nautilus conflict)
Jump to navigation Jump to search

This is an updated version of the original gnome page.

Introduction

Xmonad makes a great drop-in replacement for Gnome's default window manager (metacity) giving the user a slick tiling window manager. This guide will help you get your version of gnome up and running with xmonad 0.5.

Assumptions

For this tutorial we assume:

  • you're using xmonad 0.5 or newer.
  • you have installed the xmonad 0.5 contrib files.
  • you have a working xmonad configuration and are already familiar with the basics of configuring and using xmonad.
  • you're using GNOME 2.18 or newer. If you're using an earlier version beware that configuration dialogs and the names of certain settings could be quite different from what is illustrated here.

The configuration

All configuration is done in the ~/.xmonad/xmonad.hs file.

From scratch

To make space for the gnome-panel/taskbar at the top, we setup the ManageDocks class:

import XMonad.Hooks.ManageDocks
main = xmonad defaultConfig 
               { manageHook = manageDocks
               , layoutHook = avoidStruts (tall ||| mirror tall ||| Full)
               }
             where tall = Tall 1 (3/100) (1/2)

For gnome to know about the windows and workspaces that xmonad creates, a class called EwmhDesktop exists. The configuration (from the EwmhDesktop page)looks like this:

import XMonad
import XMonad.Hooks.EwmhDesktops
myLogHook :: X ()
myLogHook = do ewmhDesktopsLogHook
               return ()
main = xmonad defaultConfig { logHook = myLogHook }

Putting it all together, a simple xmonad.hs configuraton file that works with Gnome might be:

import XMonad
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops

myLogHook :: X ()
myLogHook = do ewmhDesktopsLogHook
               return ()
main = xmonad $ defaultConfig
                { borderWidth      = 2
                , manageHook       = manageDocks
                , workspaces       = map show [1 .. 5 :: Int]
                , logHook          = myLogHook
                , layoutHook       = avoidStruts (tall ||| Mirror tall ||| Full)
                }
              where tall = Tall 1 (3/100) (1/2)

You also need to tell gnome that you would xmonad to be your default windows manager. If gdm is your login manager, it looks in the ~/.gnomerc file for the WINDOW_MANGER variable. Let's set that. My ~/.gnomerc file looks like this:

#!/bin/bash
export WINDOW_MANAGER="/usr/bin/xmonad"

From xmonad < 0.5

To make space for the gnome-panel on the top of the screen, xmonad had to be manually configured to make space. Prior to xmonad 0.5, this was done using the defaultGaps config option. This can now safely be taken out in favor of ManageDocks. See above.

Issues

  • Shortcuts - Be weary of the keyboard shortcuts that might conflict. For example, by default xmonad uses alt as the mod key. However, the shortcut alt-space (cycle layout) conflicts with gnome's default window management shortcut.
  • Nautilus - The author has had problems when Nautilus is running. To disable it do the following:
    1. Click System -> Preferences -> Sessions
    2. Select the "Current Session" tab.
    3. Find nautilus and select it. Set style: "Trash" and press remove.
    4. On the "Session Options" tab. Press "Remember currently running applications"