Personal tools

Xmonad/Using xmonad in Gnome

From HaskellWiki

< Xmonad(Difference between revisions)
Jump to: navigation, search
m
m (need to disable draw-background in order to prevent nautilus desktop wired thing.)
(22 intermediate revisions by 17 users not shown)
Line 6: Line 6:
 
[[Image:Screen-nomeata-ewhm.png|200px|A screenshot of xmonad cooperating with gnome|center]]
 
[[Image:Screen-nomeata-ewhm.png|200px|A screenshot of xmonad cooperating with gnome|center]]
   
Xmonad makes an excellent drop-in replacement for Gnome's default window manager (metacity) giving you a slick tiling window manager. This guide will help you set up Gnome to use Xmonad 0.9.
+
Xmonad makes an excellent drop-in replacement for Gnome's default window manager (metacity) giving you a slick tiling window manager. This guide will help you set up Gnome to use XMonad >= 0.9.
  +
  +
TODO: Anyone willing to clean up this page and move out of date suggestions to a `Gnome-X.X or older page' will be entered into a drawing to win a free logApplet and taffybar installation. ;-)
   
 
This is an update to the previous page on [[Xmonad/Using xmonad in Gnome/0.6]].
 
This is an update to the previous page on [[Xmonad/Using xmonad in Gnome/0.6]].
Line 12: Line 12:
 
==Setting up Gnome to use Xmonad==
 
==Setting up Gnome to use Xmonad==
 
Overall most people on a variety of distros seem to get best results by using an <code>applications/xmonad.desktop</code> file and running a full gnome session replacing only gnome's window manager. They tell gnome-session to use xmonad instead of metacity by running:
 
Overall most people on a variety of distros seem to get best results by using an <code>applications/xmonad.desktop</code> file and running a full gnome session replacing only gnome's window manager. They tell gnome-session to use xmonad instead of metacity by running:
<pre># gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string</pre> Doing this from inside a full gnome session will replace metacity with xmonad and continue to run all the other gnome daemons and apps. See 'man gnome-wm' for <span class="plainlinks">[http://www.proposable.com <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">proposal software] details. See below to set up a separate customized xmonad or ~/.xsession based session separate from your gnome one.
+
<pre># gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string</pre> Doing this from inside a full gnome session will replace metacity with xmonad and continue to run all the other gnome daemons and apps. See 'man gnome-wm' for details. See below to set up a separate customized xmonad or ~/.xsession based session separate from your gnome one.
   
 
For xmonad to start automatically on login you need an <code>applications/xmonad.desktop</code> file on your system. If your distro doesn't provide it, create the following file:
 
For xmonad to start automatically on login you need an <code>applications/xmonad.desktop</code> file on your system. If your distro doesn't provide it, create the following file:
Line 42: Line 42:
 
</pre>
 
</pre>
   
Your display manager must also be able to find the xmonad executable. If you are not using your distro package manager to install <span class="plainlinks">[http://www.mycaal.com/ <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">loan modification] xmonad, for best results configure your build to install xmonad to a location in the system environment like /usr/local/bin/.
+
Your display manager must also be able to find the xmonad executable. If you are not using your distro package manager to install xmonad, for best results configure your build to install xmonad to a location in the system environment like /usr/local/bin/.
   
 
<nowiki>*NOTE:</nowiki> Using an <code>xsessions/xmonad.desktop</code> file that runs a custom script <code>xmonad.start</code> instead of just plain xmonad is also how to add other startup actions to the gdm xmonad.desktop startup, such as starting gnome daemons, apps, etc. See
 
<nowiki>*NOTE:</nowiki> Using an <code>xsessions/xmonad.desktop</code> file that runs a custom script <code>xmonad.start</code> instead of just plain xmonad is also how to add other startup actions to the gdm xmonad.desktop startup, such as starting gnome daemons, apps, etc. See
Line 48: Line 48:
   
 
====Gnome3====
 
====Gnome3====
[http://therning.org/magnus/archives/938 This blog post] has instructions for integrating xmonad with Gnome3 on archlinux. It should also work for most other distros that don't work out of the box. (E.g. Fedora 15 should "just work".)
+
[http://therning.org/magnus/archives/938 This blog post] has instructions for integrating xmonad with Gnome3 on archlinux. It should also work for most other distros that don't work out of the box. (E.g. Fedora 15 should "just work".) Note that these instructions will not work with a fresh Ubuntu 11.10 install, since bits of Gnome are missing in the release. (See below for details.)
  +
  +
With Debian (and probably other distributions) you can also create a
  +
custom, user-specific session. For example, assume you would like to
  +
run XMonad with Gnome, but without any Gnome panels; you can do so
  +
like like this.
  +
  +
Create a ~/.config/gnome-session/sessions/xmonad-gnome-nopanel.session file like this:
  +
<pre>
  +
[GNOME Session]
  +
Name=XMonad/Gnome (without gnome-panel)
  +
RequiredComponents=gnome-settings-daemon;
  +
RequiredProviders=windowmanager;notifications;
  +
DefaultProvider-windowmanager=xmonad
  +
DefaultProvider-notifications=notification-daemon
  +
</pre>
  +
  +
Create an executable ~/.xsession file, symlinked from ~/.xinitrc like this:
  +
  +
<pre>exec gnome-session --session xmonad-gnome-nopanel "$@"</pre>
  +
  +
And then specify "System Default" for the session when logging in via gdm3.
  +
  +
Finally, note that many Gnome3 features such as the gnome shell are part of the mutter window manager. You can't use part of mutter plus part of some other window manager.
   
Note that many Gnome3 features such as the gnome shell are part of the mutter window manager. You can't use part of mutter plus part of some other window manager.
 
 
====A Simple Hybrid Alternative====
 
====A Simple Hybrid Alternative====
 
There is also a hybrid method that seems to work much more simply and easily than the custom start script, while still allowing XMonad to be chosen as a separate session. <code>applications/xmonad.desktop</code> and <code>xsessions/xmonad.desktop</code> are created as above. And, as above, <code>xsessions/xmonad.desktop</code> points to a custom <code>xmonad.start</code> script. But, the contents of the xmonad.start script are simply the following:
 
There is also a hybrid method that seems to work much more simply and easily than the custom start script, while still allowing XMonad to be chosen as a separate session. <code>applications/xmonad.desktop</code> and <code>xsessions/xmonad.desktop</code> are created as above. And, as above, <code>xsessions/xmonad.desktop</code> points to a custom <code>xmonad.start</code> script. But, the contents of the xmonad.start script are simply the following:
Line 58: Line 57:
 
</pre>
 
</pre>
   
This gives all the bells and whistles of gnome, including integrated logout support, etc, while also allowing xmonad and gnome to be selected as separate sessions from the login screen. Note that if you go this road with Ubuntu 10.04 (tested with gnome 2.30.0), you will also need <span class="plainlinks">[http://www.bestpills4weightloss.com/ <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">weight loss pills for women</span>] to unset the gconf windowmanager setting.
+
This gives all the bells and whistles of gnome, including integrated logout support, etc, while also allowing xmonad and gnome to be selected as separate sessions from the login screen. Note that if you go this road with Ubuntu 10.04 (tested with gnome 2.30.0), you will also need to unset the gconf windowmanager setting.
   
 
<code>gconftool-2 -u /desktop/gnome/session/required_components/windowmanager</code>
 
<code>gconftool-2 -u /desktop/gnome/session/required_components/windowmanager</code>
Line 73: Line 72:
 
xmonad &
 
xmonad &
 
</pre>
 
</pre>
  +
  +
===Debian===
  +
  +
The Debian xmonad package comes, since version 0.9.2-3, with the file necessary to start a GNOME3-Fallback session with xmonad instead of metacity from GDM; just select it from the list of possible sessions. Eventually, when the new package migrates there, this will also hold for Ubuntu.
   
 
===Ubuntu===
 
===Ubuntu===
  +
  +
[See below for version-specific instructions]
  +
 
I had tried above methods described by "simple hybrid", but they are not staight forward and didn't work.
 
I had tried above methods described by "simple hybrid", but they are not staight forward and didn't work.
 
<pre>
 
<pre>
Line 87: Line 93:
 
Finally it works! This indirectly prove the above guess is right.
 
Finally it works! This indirectly prove the above guess is right.
 
Actually I had put this script to xmonad-custom.start, then I can have gnome and xmonad session seperated, and they don't interfere with the other. I think this method is simple yet elegant, and easy to understand.
 
Actually I had put this script to xmonad-custom.start, then I can have gnome and xmonad session seperated, and they don't interfere with the other. I think this method is simple yet elegant, and easy to understand.
  +
  +
===Ubuntu Precise===
  +
Installing xmonad in Precise adds a "GNOME with XMonad" session option, but as of 2012-07-11, this session doesn't work out-of-the-box, due to a missing gnome-panel dependency (see https://bugs.launchpad.net/ubuntu/+source/xmonad/+bug/989405). Installing gnome-panel ("sudo apt-get install gnome-panel") adds the missing dependency and allows built-in session to function properly.
  +
  +
Alternatively, it's possible to customize the Gnome Classic session by adding the following to ~/.gnomerc
  +
<pre>
  +
export WINDOW_MANAGER=xmonad
  +
</pre>
  +
and using an xmonad.hs like the following
  +
<pre>
  +
import XMonad
  +
import XMonad.Config.Gnome
  +
  +
main = do
  +
xmonad $ gnomeConfig
  +
</pre>
  +
  +
===Ubuntu Oneiric===
  +
  +
[These instructions assume you've installed Ubuntu's xmonad package from apt and might not work for cabal or source installs.]
  +
  +
To set up Gnome to use Xmonad in Oneiric, you first need to add a new Gnome Session description to /usr/share/gnome-session/sessions/. Save the following as xmonad.session:
  +
  +
<pre>
  +
[GNOME Session]
  +
Name=Xmonad/GNOME
  +
RequiredComponents=gnome-settings-daemon;
  +
RequiredProviders=windowmanager;
  +
DefaultProvider-windowmanager=xmonad
  +
</pre>
  +
  +
Next you need to create an Xsession description. If you installed Xmonad from apt you'll already have an Xsession for running Xmonad without Gnome at /usr/share/xsessions/xmonad.desktop. You can either overwrite that default session (not recommended) or create a new one at /usr/share/xsessions/xmonad-gnome.desktop which looks like this:
  +
  +
<pre>
  +
[Desktop Entry]
  +
Name=Xmonad/GNOME
  +
Comment=Tiling window manager
  +
Exec=gnome-session --session=xmonad
  +
TryExec=/usr/bin/gnome-session
  +
Type=XSession
  +
</pre>
  +
  +
This should add an entry to the sessions menu in LightDM, called Xmonad/GNOME. Select this option before you log in to start a Gnome session with Xmonad goodness.
  +
  +
To make this the default session, change /etc/lightdm/lightdm.conf so that it contains the line
  +
<pre>
  +
user-session=SESSION_NAME
  +
</pre>
  +
where SESSION_NAME should be the name of the Xsession defined above (we suggested xmonad-gnome).
  +
  +
Note that Ubuntu's flavour of Gnome 3 shows the menu bar for the focused window at the top of the screen, presumably because Unity wants it there. Even in Classic Gnome, it's there, hiding behind gnome-panel. There should be an option in dconf-editor that will make it go away.
   
 
===Ubuntu Natty===
 
===Ubuntu Natty===
Line 274: Line 331:
 
===Disable the Nautilus desktop===
 
===Disable the Nautilus desktop===
   
This step is not required, but some users prefer to disable the desktop. From the command line execute:
+
This step is not required, but some users prefer to disable the desktop.
  +
  +
In Gnome 2, execute the following at the command line:
   
 
gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false
 
gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false
   
 
(Using recent gnome and xmonad I found that it was necessary.)
 
(Using recent gnome and xmonad I found that it was necessary.)
  +
  +
In Gnome 3, execute dconf-editor, then go to org > gnome > desktop > background. From there you can deselect show-desktop-icons to prevent nautilus from handling the desktop.
  +
  +
(Update-2012-10-19: deselect ''show-desktop-icons'' is not enough for me and I have to deselect ''draw-background'' as well.)
   
 
===Changing desktop background===
 
===Changing desktop background===
Line 351: Line 412:
   
 
("M-S-q", spawn "gnome-session-save --gui --logout-dialog") )
 
("M-S-q", spawn "gnome-session-save --gui --logout-dialog") )
  +
  +
In Gnome 3, "gnome-session-save" was renamed to "gnome-session-quit" and defaults to prompting with a dialog:
  +
  +
("M-S-q", spawn "gnome-session-quit") )
   
 
==== Configure rudimentary power management ====
 
==== Configure rudimentary power management ====
Line 369: Line 434:
 
, ("M1-S-p", spawn "gnome-power-cmd.sh shutdown")
 
, ("M1-S-p", spawn "gnome-power-cmd.sh shutdown")
   
  +
In Gnome 3, replace "gnome-session-save --gui --kill" with "gnome-session-quit --no-prompt".
   
 
====Configure the session manager to relaunch Xmonad====
 
====Configure the session manager to relaunch Xmonad====

Revision as of 08:38, 19 October 2012

Xmonad-logo-small.png

XMonad

Contents

1 Introduction

A screenshot of xmonad cooperating with gnome

Xmonad makes an excellent drop-in replacement for Gnome's default window manager (metacity) giving you a slick tiling window manager. This guide will help you set up Gnome to use XMonad >= 0.9.

TODO: Anyone willing to clean up this page and move out of date suggestions to a `Gnome-X.X or older page' will be entered into a drawing to win a free logApplet and taffybar installation. ;-)

This is an update to the previous page on Xmonad/Using xmonad in Gnome/0.6.

2 Setting up Gnome to use Xmonad

Overall most people on a variety of distros seem to get best results by using an applications/xmonad.desktop file and running a full gnome session replacing only gnome's window manager. They tell gnome-session to use xmonad instead of metacity by running:

# gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string
Doing this from inside a full gnome session will replace metacity with xmonad and continue to run all the other gnome daemons and apps. See 'man gnome-wm' for details. See below to set up a separate customized xmonad or ~/.xsession based session separate from your gnome one.

For xmonad to start automatically on login you need an applications/xmonad.desktop file on your system. If your distro doesn't provide it, create the following file:

$ 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

Alternatively, you can create the above as ~/.local/share/applications/xmonad.desktop for the current user only.

To run a separate xmonad session in addition to gnome session(s) you need an xsessions/xmonad.desktop file. To start a minimal xmonad session from gdm (see notes* below to run more than just xmonad on login), create the following file:

$ cat /usr/share/xsessions/xmonad.desktop 
[Desktop Entry]
Encoding=UTF-8
Name=XMonad
Comment=Lightweight tiling window manager
Exec=xmonad
Icon=xmonad.png
Type=XSession

Your display manager must also be able to find the xmonad executable. If you are not using your distro package manager to install xmonad, for best results configure your build to install xmonad to a location in the system environment like /usr/local/bin/.

*NOTE: Using an xsessions/xmonad.desktop file that runs a custom script xmonad.start instead of just plain xmonad is also how to add other startup actions to the gdm xmonad.desktop startup, such as starting gnome daemons, apps, etc. See arjuna's blog for more details. (simono says: Creating /usr/share/xsessions/xmonad.desktop and /usr/local/bin/xmonad.start files is the preferred method for configuring an alternative window manager. The applications/xmonad.desktop file is still required.) However, see the xsession section below to continue using the classic ~/.xsession method to run a custom session.

2.1 Gnome3

This blog post has instructions for integrating xmonad with Gnome3 on archlinux. It should also work for most other distros that don't work out of the box. (E.g. Fedora 15 should "just work".) Note that these instructions will not work with a fresh Ubuntu 11.10 install, since bits of Gnome are missing in the release. (See below for details.)

With Debian (and probably other distributions) you can also create a custom, user-specific session. For example, assume you would like to run XMonad with Gnome, but without any Gnome panels; you can do so like like this.

Create a ~/.config/gnome-session/sessions/xmonad-gnome-nopanel.session file like this:

  [GNOME Session]
  Name=XMonad/Gnome (without gnome-panel) 
  RequiredComponents=gnome-settings-daemon;
  RequiredProviders=windowmanager;notifications;
  DefaultProvider-windowmanager=xmonad
  DefaultProvider-notifications=notification-daemon
  

Create an executable ~/.xsession file, symlinked from ~/.xinitrc like this:

exec gnome-session --session xmonad-gnome-nopanel "$@"

And then specify "System Default" for the session when logging in via gdm3.

Finally, note that many Gnome3 features such as the gnome shell are part of the mutter window manager. You can't use part of mutter plus part of some other window manager.

2.2 A Simple Hybrid Alternative

There is also a hybrid method that seems to work much more simply and easily than the custom start script, while still allowing XMonad to be chosen as a separate session. applications/xmonad.desktop and xsessions/xmonad.desktop are created as above. And, as above, xsessions/xmonad.desktop points to a custom xmonad.start script. But, the contents of the xmonad.start script are simply the following:

export WINDOW_MANAGER=xmonad
gnome-session

This gives all the bells and whistles of gnome, including integrated logout support, etc, while also allowing xmonad and gnome to be selected as separate sessions from the login screen. Note that if you go this road with Ubuntu 10.04 (tested with gnome 2.30.0), you will also need to unset the gconf windowmanager setting.

gconftool-2 -u /desktop/gnome/session/required_components/windowmanager

That alone didn't work for me. I have this in my xmonad.start instead

gconftool-2 -t string -s /desktop/gnome/session/required_components/windowmanager xmonad
gconftool-2 -t string -s /desktop/gnome/applications/window_manager/current xmonad

After startup I am running

killall compiz
xmonad &

2.3 Debian

The Debian xmonad package comes, since version 0.9.2-3, with the file necessary to start a GNOME3-Fallback session with xmonad instead of metacity from GDM; just select it from the list of possible sessions. Eventually, when the new package migrates there, this will also hold for Ubuntu.

2.4 Ubuntu

[See below for version-specific instructions]

I had tried above methods described by "simple hybrid", but they are not staight forward and didn't work.

export WINDOW_MANAGER=/path to xmonad
gnome-sesson

If once I execute "gnome-wm" manually, after that it works, I got xmonad integrated in gnome well. However, once I switch to my gnome session, and then return back to my xmonad session, the xmonad window manager isn't run, just as I log into the gnome session.

After delving into gnome-wm script and some analysis and many try, I found out why the plain script did not work. Because I had turned on the "auto save gnome session" function, I guess gnome-session wouldn't call gnome-wm again when I change from gnome session to xmonad session. So I disable the save session function, and remove the files in .config/gnome-session/saved-session/*.

Finally it works! This indirectly prove the above guess is right. Actually I had put this script to xmonad-custom.start, then I can have gnome and xmonad session seperated, and they don't interfere with the other. I think this method is simple yet elegant, and easy to understand.

2.5 Ubuntu Precise

Installing xmonad in Precise adds a "GNOME with XMonad" session option, but as of 2012-07-11, this session doesn't work out-of-the-box, due to a missing gnome-panel dependency (see https://bugs.launchpad.net/ubuntu/+source/xmonad/+bug/989405). Installing gnome-panel ("sudo apt-get install gnome-panel") adds the missing dependency and allows built-in session to function properly.

Alternatively, it's possible to customize the Gnome Classic session by adding the following to ~/.gnomerc

export WINDOW_MANAGER=xmonad

and using an xmonad.hs like the following

import XMonad
import XMonad.Config.Gnome

main = do
    xmonad $ gnomeConfig

2.6 Ubuntu Oneiric

[These instructions assume you've installed Ubuntu's xmonad package from apt and might not work for cabal or source installs.]

To set up Gnome to use Xmonad in Oneiric, you first need to add a new Gnome Session description to /usr/share/gnome-session/sessions/. Save the following as xmonad.session:

[GNOME Session]
Name=Xmonad/GNOME
RequiredComponents=gnome-settings-daemon;
RequiredProviders=windowmanager;
DefaultProvider-windowmanager=xmonad

Next you need to create an Xsession description. If you installed Xmonad from apt you'll already have an Xsession for running Xmonad without Gnome at /usr/share/xsessions/xmonad.desktop. You can either overwrite that default session (not recommended) or create a new one at /usr/share/xsessions/xmonad-gnome.desktop which looks like this:

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

This should add an entry to the sessions menu in LightDM, called Xmonad/GNOME. Select this option before you log in to start a Gnome session with Xmonad goodness.

To make this the default session, change /etc/lightdm/lightdm.conf so that it contains the line

user-session=SESSION_NAME

where SESSION_NAME should be the name of the Xsession defined above (we suggested xmonad-gnome).

Note that Ubuntu's flavour of Gnome 3 shows the menu bar for the focused window at the top of the screen, presumably because Unity wants it there. Even in Classic Gnome, it's there, hiding behind gnome-panel. There should be an option in dconf-editor that will make it go away.

2.7 Ubuntu Natty

2.7.1 Using New Session Files

On Natty you need to create a new gnome session description at

/usr/share/gnome-session/sessions/xmonad.session which should look something like this

[GNOME Session]
Name=Xmonad
Required=windowmanager;panel;filemanager;
Required-windowmanager=xmonad
Required-panel=gnome-panel
Required-filemanager=nautilus
DefaultApps=gnome-settings-daemon;

You should also create a file at /usr/share/xsessions/xmonad.desktop with contents like this

[Desktop Entry]
Name=XMonad
Comment=Lightweight tiling window manager + Gnome
Exec=gnome-session --session=xmonad
Icon=
Type=Application
X-Ubuntu-Gettext-Domain=gnome-session-2.0

And then select the Xmonad session when logging in with GDM.

I also had to uninstall the appmenu stuff to get my menus back for some reason. Not sure what the problem with the global menus are in Natty since the Gnome Classic session gets normal in-window menus and the appmenu panel still works. With xmonad it just seems totally broken.

2.7.2 Using GConf

Rather than having an administrator create new .desktop and .session files, an unprivileged user may configure gnome-wm to use Xmonad as Gnome's window manager through GConf as described at #Setting_up_Gnome_to_use_Xmonad.

This approach worked in previous versions of Ubuntu but at present with Natty, if /usr/lib/nux/unity_support_test is not installed, an administrator may have to comment out or remove the IsRunnableHelper line from /usr/share/xsessions/gnome-classic.desktop:

   # IsRunnableHelper=/usr/lib/nux/unity_support_test --compiz

Logging in using the "Ubuntu Classic" session will then launch Xmonad and all the other Gnome widgets. See also Ubuntu Bug#774357.

2.8 Ubuntu Karmic

Follow the above general instructions. Most people will probably want to use the "simple hybrid method", .xsession, or use gconftool to replace metacity in a full gnome session running all the other supporting gnome apps. You may also wish to install xterm if you don't already have it, since it's the terminal used by the default xmonad setup, at least till you get the gnomeConfig up and running as discussed in later sections.

2.8.1 using xsession under karmic

*NOTE:Ubuntu Karmic Koala users still can use their ~/.xsession scripts to run xmonad. For this, you need:

1. sudo mkdir /etc/X11/sessions

2. put into /etc/X11/sessions/Xsessions.desktop:

[Desktop Entry]
Name=Xsession
Comment=This runs ~/.xsession
Exec=/etc/X11/Xsession

3. Then Xsession entry will appear in gdm, and will work as it worked for many years.

WINDOW_MANAGER variable looks still working, you can use smth like:

export WINDOW_MANAGER="/path/to/xmonad"
exec gnome-session 

in your ~/.xsession

For more info on this, check gdm bug description at launchpad [1].

2.8.2 xmonad-0.9 for karmic

This mailing list thread has instructions to use a PPA for newer xmonad, dzen, xmobar.

2.9 Ubuntu Jaunty

At least 3 XMonad users have found that the ~/.gnomerc will not work on Jaunty Ubuntu when one is upgrading from Intrepid; apparently the ~/.gconf/ directory is incompatible or something, so Gnome/Ubuntu will not read .gnomerc and any settings in it will be ignored.

The work-around is essentially to remove .gconf entirely. On the next login, a fresh default .gconf will be created and .gnomerc will be read. This of course implies that one's settings and preferences will also be removed, and one will have to redo them. (Copying over selected directories from the old .gconf to the new one may or may not work.)

Or alternatively, the following worked for me (without touching .gconf or .gnomerc or exports): Add an xmonad launcher in the gnome-session-properties and then execute:

   $ gconftool -t string -s /desktop/gnome/applications/window_manager/current xmonad
   $ gconftool -t string -s /desktop/gnome/session/required_components/windowmanager xmonad
   $ killall metacity; xmonad &

Also make sure to add the /usr/share/applications/xmonad.desktop file shown above, if it's not already present. This lets gnome know that xmonad is a windowmanager and where to look for it.

2.9.1 newer haskell and xmonad for jaunty

gspreemann's PPA has newer haskell toolchain without some of the setup problems others have had, as well as xmonad-0.9.

2.10 Ubuntu Intrepid

This forum thread has instructions for making Gnome play nice with xmonad on intrepid.



2.11 Fedora

Recent Fedora xmonad packages provide /usr/share/applications/xmonad.desktop and /usr/share/xsessions/xmonad.desktop, so the above generic instructions should "just work" (but not the "Simple Hybrid Alternative").

2.11.1 Fedora 15

Installing xmonad or bluetile should "just work" out of the box. Select "xmonad GNOME" or "GNOME + bluetile" at the gdm prompt.

2.11.2 Fedora 10 and further links

This old mailing list thread contains fedora 10 specific setup instructions, but also a bunch of other gnome setup links if you are having trouble with the above methods.

2.12 Using the startup applications menu to modify your gnome session

An alternative to using gconftool to change the window manager in a gnome session:

On many distros you can replace metacity in your full gnome session by using the gnome menus to create a new item in the System>Preferences>Startup Applications menu Programs tab to run xmonad as window manager. (Disable "automatic saving of session components on logout" to use this setup method.)

For example, for Name: you could use "Window Manager XMonad", then for Program: use xmonad. Un-check the old Metacity one (typically called Window Manager and using Program gnome-wm). Don't delete or over-write it so you can switch back if you want. Click the checkbox to turn on the new "Window Manager XMonad" entry instead, save your session, log out and log back in choosing gnome-session. If it's not already there, this will create the applications/xmonad.desktop file discussed above. (Not a great method for people who switch frequently between metacity, compiz, and xmonad.)

3 Configure Xmonad to interoperate with Gnome

xmonad and gnome-panel

3.1 Using the Config.Gnome module

For xmonad-0.8 or greater, see Basic DE Integration for a simple three line xmonad.hs configuration that:

  • integrates docks and gnome-panel using ewmh's
  • allows gap-toggling
  • binds the gnome run dialog to mod-p, and mod-shift-q to save your session and logout
  • otherwise keeps xmonad defaults.

It is a good starting point. You can then come back and add some of the features below once everything's working.

Once the Config.Gnome module set up, you may want to customize these gnome settings.

3.1.1 Keys

Use EZConfig to add keybindings. Note that you must use gnomeConfig whereever defaultConfig is mentioned.

import XMonad
import XMonad.Util.EZConfig
main = xmonad $ gnomeConfig
        { terminal = "urxvt"
        , modMask = mod4Mask -- set the mod key to the windows key
        }
        `additionalKeysP` 
                 [ ("M-m", spawn "echo 'Hi, mom!' | dzen2 -p 4")
                 , ("M-<Backspace>", withFocused hide) -- N.B. this is an absurd thing to do
                 ]

3.1.2 ManageHooks

Be sure to include the default gnome manageHook when overriding manageHooks so that xmonad can leave a gap for gnome-panel:

main = xmonad gnomeConfig
   {
   ...
   , manageHook = composeAll
        [ manageHook gnomeConfig
        , title =? "foo" --> doShift "2"
        -- needs: import XMonad.Hooks.ManageHelpers (isFullscreen,doFullFloat)
        , isFullscreen --> doFullFloat
        ]
   ...
   }

3.1.3 Layouts

When overriding the default layouts, you must manually apply the desktopLayoutModifiers layout modifier.

import XMonad.Config.Desktop (desktopLayoutModifiers)
main = xmonad gnomeConfig
    {
    ...
    , layoutHook = desktopLayoutModifiers (Tall 1 0.03 0.5 ||| Full)
    ...
    }
A screenshot of xmonad cooperating with gnome

4 Tweak Gnome to work better with Xmonad

These are a few steps that greatly improves the experience of running Xmonad under Gnome. Note that on some systems the binary gconftool is called gconftool-2.

4.1 Disable the Nautilus desktop

This step is not required, but some users prefer to disable the desktop.

In Gnome 2, execute the following at the command line:

   gconftool --type boolean --set /apps/nautilus/preferences/show_desktop false

(Using recent gnome and xmonad I found that it was necessary.)

In Gnome 3, execute dconf-editor, then go to org > gnome > desktop > background. From there you can deselect show-desktop-icons to prevent nautilus from handling the desktop.

(Update-2012-10-19: deselect show-desktop-icons is not enough for me and I have to deselect draw-background as well.)

4.2 Changing desktop background

If you need to change the workspace background programmatically (i.e. from some extension setting in xmonad's configuration file), you can use the command:

   gconftool --type string --set /desktop/gnome/background/picture_filename "/path/to/your/image.png"

4.3 Display XMonad logHook in gnome-panel

See xmonad log applet for a third party panel applet to display xmonad's logHook in gnome-panel via dbus. You will also need to install the DBus package from hackage. For more detailed installation and setup instructions, see Installing xmonad log applet.

4.4 Key bindings for switching desktops

4.4.1 In 1 dimension: CycleWS

Gnome lays out the desktops in a row by default, and uses Ctrl+Alt+Left/Right for switching desktops left/right. To get similar behaviour in Xmonad, you need to add some keybindings. The contrib module XMonad.Actions.CycleWS has some useful actions for cycling workspaces:

main = xmonad gnomeConfig
    { modMask = mod4Mask }
    `additionalKeysP`
    [
    ...
    -- moving workspaces
    , ("M-<Left>",    prevWS )
    , ("M-<Right>",   nextWS )
    , ("M-S-<Left>",  shiftToPrev )
    , ("M-S-<Right>", shiftToNext )
    ]
Xmonad-screen-gnome-brownblack5.jpg

4.4.2 In 2 dimensions: Plane

If Gnome is configured to lay out desktops in more than one line, it's possible to navigate with Ctrl+Alt+Up/Bottom also. The contrib module XMonad.Actions.Plane, available in the xmonad-0.8 or greater. The keybindings can be incorporated in with EZConfig as such:

import XMonad
import XMonad.Config.Gnome
import XMonad.Actions.Plane
import XMonad.Util.EZConfig
import qualified Data.Map as M
main = xmonad $ gnomeConfig
    { terminal = "urxvt"
    , modMask = mod4Mask -- set the mod key to the windows key
    }
    `additionalKeysP` 
        [ ("M-m", spawn "echo 'Hi, mom!' | dzen2 -p 4")
        , ("M-<Backspace>", withFocused hide) -- N.B. this is an absurd thing to do
        ]
    `additionalKeys`
    -- NOTE: planeKeys requires xmonad-0.9 or greater
    M.toList (planeKeys mod4Mask GConf Finite)

Actions.WorkspaceCursors can be used to navigate workspaces arranged in three or more dimensions.

4.5 Logging out of the Gnome session vs. quitting Xmonad

When running Xmonad as above, it is launched by gnome-session, the "Gnome session manager." Quitting Xmonad in this situation will not log you out. If you make no changes, using mod+shift+q will leave you with all your applications still running and no window manager to navigate them! There are several remedies for this.

  * Run 'xmonad &' from a command line.
  * Quit X using Alt-Ctrl-Backspace.
  * Rebind mod+shift+q

4.5.1 Rebind mod+shift+q

To avoid exiting Xmonad and being stuck with no window manager, you might rebind mod+shift+q to execute the gnome-session "log out" functionality. This will of course prevent you from "quitting" Xmonad in the normal way, which may or may not be desirable. When the session logs out, the X11 server is terminated, which will in turn terminate all running X11 applications, including Xmonad.

The following mapping in `additionalKeysP` effects this change.

   ("M-S-q", spawn "gnome-session-save --gui --logout-dialog") )

In Gnome 3, "gnome-session-save" was renamed to "gnome-session-quit" and defaults to prompting with a dialog:

   ("M-S-q", spawn "gnome-session-quit") )

4.5.2 Configure rudimentary power management

It might be useful to include bindings for hibernation, screen locking, and other assorted basic functions. While Gnome provides the capability to do so, it's functionality is limited (Mod4 cannot be used as a mask), and you may prefer to have Xmonad manage it. Fortunately, these things can be controlled from the command line, and the following bindings may help. (NB: These are for one handed use of Dvorak control; make sure to bind them to something more fitting. They also use mod1 not to clash with mod4 by accident.)

    -- Lock Screen
    , ("M-S-l",    spawn "gnome-screensaver-command -l")
    -- Logout
    , ("M1-M-S-l", spawn "gnome-session-save --gui --kill")
    -- Sleep
    , ("M1-S-'",   spawn "gnome-power-cmd.sh suspend")
    -- Reboot
    , ("M1-S-,",   spawn "gnome-power-cmd.sh reboot")
    -- Deep Sleep
    , ("M1-S-.",   spawn "gnome-power-cmd.sh hibernate")
    -- Death
    , ("M1-S-p",   spawn "gnome-power-cmd.sh shutdown")

In Gnome 3, replace "gnome-session-save --gui --kill" with "gnome-session-quit --no-prompt".

4.5.3 Configure the session manager to relaunch Xmonad

You can configure the Gnome Session Manager to restart Xmonad whenever it exits (i.e., if you haven't rebound mod-shift-q.) This is rarely a useful feature as xmonad has its builtin compile-and-restart (mod-q), but it will prevent you from accidentally ending up with no window manager and no way to launch one.

However, as of version 0.7, XMonad does not itself communicate with any session managers in they way they prefer, so setting things up takes some hackery:

(TBD: steps, see also Xmonad/Using_xmonad_in_Gnome/0.5#Preparing_your_GNOME_session)

4.6 Modify terminal

If you use prompts, e.g. SshPrompt, due to an issue with how the terminal is invoked (see [2]), you will need to either wrap gnome-terminal as described here and then do something like

main = xmonad $ gnomeConfig { terminal = "/path/to/gnome-terminal-wrapper" }

or use a different terminal altogether

main = xmonad $ gnomeConfig { terminal = "xterm" }