Personal tools

Xmonad/Using xmonad in XFCE

From HaskellWiki

< Xmonad(Difference between revisions)
Jump to: navigation, search
(Change 1 Level headlines to 2 Level headlines as stated in HaskellWiki:Guidelines#Headlines)
(7 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
[[Category:XMonad]]
 
[[Category:XMonad]]
   
=Introduction=
+
== Introduction ==
   
 
This is an updated and hopefully less confusing version of my original blog post located here: [http://ivanmiljenovic.wordpress.com/2008/01/20/xmonad/ X<sup>2</sup>Monad]
 
This is an updated and hopefully less confusing version of my original blog post located here: [http://ivanmiljenovic.wordpress.com/2008/01/20/xmonad/ X<sup>2</sup>Monad]
Line 10: Line 10:
 
Whilst XMonad is a truly excellent Window Manager, alone it doesn't offer the full convenience of an entire Desktop Environment, such as the provided menus, all-in-one configuration settings, consistent dialogs, etc. Out of the three main DEs available in Unix-like Operating Systems - Gnome, KDE and Xfce - the latter is often touted as the most "nimble" of the lot. In my own opinion, it is simpler to use than KDE but with more configuration options (and a saner environment) than Gnome.
 
Whilst XMonad is a truly excellent Window Manager, alone it doesn't offer the full convenience of an entire Desktop Environment, such as the provided menus, all-in-one configuration settings, consistent dialogs, etc. Out of the three main DEs available in Unix-like Operating Systems - Gnome, KDE and Xfce - the latter is often touted as the most "nimble" of the lot. In my own opinion, it is simpler to use than KDE but with more configuration options (and a saner environment) than Gnome.
   
= Configuring XMonad to work with Xfce =
+
== Configuring XMonad to work with Xfce ==
   
 
This guide assumes that you're using at least version 4.4 of Xfce, and have both XMonad and XMonad-Contrib 0.7 installed. First we need to configure Xfce to play nicely, before adding in XMonad.
 
This guide assumes that you're using at least version 4.4 of Xfce, and have both XMonad and XMonad-Contrib 0.7 installed. First we need to configure Xfce to play nicely, before adding in XMonad.
   
==Xfce Settings==
+
=== Xfce Settings ===
   
 
We're going to utilise Xfce's Session Manager to make sure that xfwm4 (Xfce's default WM) is no longer started. Preferably, it'd be nice if we could have XMonad started this way as well (or even set in a configuration option like with Gnome or KDE), but the former isn't possible until XMonad supports the required Session Management Protocol and the latter isn't possible in Xfce at all.
 
We're going to utilise Xfce's Session Manager to make sure that xfwm4 (Xfce's default WM) is no longer started. Preferably, it'd be nice if we could have XMonad started this way as well (or even set in a configuration option like with Gnome or KDE), but the former isn't possible until XMonad supports the required Session Management Protocol and the latter isn't possible in Xfce at all.
   
===Backing up your settings===
+
==== Backing up your settings ====
   
 
If you're already using Xfce, you may wish to first backup your ~/.config directory. Whilst Xfce isn't the only application/library/etc. to utilise the ~/.config directory to store it's settings, it does so in a few different sub-directories (i.e. in some cases specific applications have their own settings directory), it's easier to backup the whole thing.
 
If you're already using Xfce, you may wish to first backup your ~/.config directory. Whilst Xfce isn't the only application/library/etc. to utilise the ~/.config directory to store it's settings, it does so in a few different sub-directories (i.e. in some cases specific applications have their own settings directory), it's easier to backup the whole thing.
Line 24: Line 24:
 
Note that as far as I know, it isn't possible to have for the same user both a standard Xfce login and an XMonad Xfce login. Whilst you can have different sessions to determine whether you use XMonad or not, there are some settings - such as the panel layout - that aren't saved on a per-session basis.
 
Note that as far as I know, it isn't possible to have for the same user both a standard Xfce login and an XMonad Xfce login. Whilst you can have different sessions to determine whether you use XMonad or not, there are some settings - such as the panel layout - that aren't saved on a per-session basis.
   
===Start a new session===
+
==== Start a new session ====
   
 
For backup purposes in case something goes wrong with your XMonad settings, it is recommended to create a new Xfce session. To do so, open the "Sessions and Startup" option dialog either from the "Settings" section of the Xfce menu, or in Xfce's Settings Manager (xfce-setting-show). Enable the the session chooser and automatic saving of sessions, then logout and log back in again. When the session chooser appears, choose to create a new session.
 
For backup purposes in case something goes wrong with your XMonad settings, it is recommended to create a new Xfce session. To do so, open the "Sessions and Startup" option dialog either from the "Settings" section of the Xfce menu, or in Xfce's Settings Manager (xfce-setting-show). Enable the the session chooser and automatic saving of sessions, then logout and log back in again. When the session chooser appears, choose to create a new session.
Line 30: Line 30:
 
A word of warning: I found that the session chooser kept crashing Xfce on a freshly installed Xfce-4.4.2. If this happens to you, delete the ~/.config/xfce-session directory.
 
A word of warning: I found that the session chooser kept crashing Xfce on a freshly installed Xfce-4.4.2. If this happens to you, delete the ~/.config/xfce-session directory.
   
===Setting up Xfce===
+
==== Setting up Xfce ====
   
 
Open up the Xfce settings manager. There, you can customise Xfce to your hearts content. Note that the following settings dialogs won't be applicable once we start XMonad:
 
Open up the Xfce settings manager. There, you can customise Xfce to your hearts content. Note that the following settings dialogs won't be applicable once we start XMonad:
Line 46: Line 46:
 
If you so wish, you can now disable the session chooser, though I suggest you leave it enabled until you've successfully managed to login to your Xfce/XMonad environment several times.
 
If you so wish, you can now disable the session chooser, though I suggest you leave it enabled until you've successfully managed to login to your Xfce/XMonad environment several times.
   
===Xfce's Panels===
+
==== Xfce's Panels ====
   
 
If you so wish you can now customize the panels and the plugins on them. This can be safely left to later, however. With XMonad, I typically only have one panel rather than the default two. In terms of panel plugins, I've removed the Task List, but kept the pager: with the EWMH settings in XMonad, Xfce's pager acts as a mini-preview of your various layouts!
 
If you so wish you can now customize the panels and the plugins on them. This can be safely left to later, however. With XMonad, I typically only have one panel rather than the default two. In terms of panel plugins, I've removed the Task List, but kept the pager: with the EWMH settings in XMonad, Xfce's pager acts as a mini-preview of your various layouts!
   
===Ensure XMonad gets started===
+
==== Ensure XMonad gets started ====
   
Because XMonad doesn't support the session protocol and Xfce is missing an option to specify which Window Manager to use, we must ensure that XMonad is started each time we log in. '''WARNING!!! Make sure you don't log out and back in again after setting this and before you reach the stage where we kill xfwm4, or else you will have two different Window Managers fighting each other!!!''' Run Xfce's Autostarted Applications manager (either under the Settings section in the Xfce menu or run <code>xfce4-autostart-editor</code>). There, add a new autostarted application with the command being simply <code>xmonad</code> (this of course assumes XMonad is in your path... otherwise, specify the full path to the binary) with whatever name you want. Ensure that the new autostarted application entry you just created is ticked.
+
Because XMonad doesn't support the session protocol and Xfce is missing an option to specify which Window Manager to use, we must ensure that XMonad is started each time we log in. '''WARNING!!! Make sure you don't log out and back in again after setting this and before you reach the stage where we kill xfwm4, or else you will have two different Window Managers fighting each other!!!''' Run Xfce's Autostarted Applications manager (either under the Settings section in the Xfce menu (Menu -> Settings -> Setting Manager -> Sessin and Startup -> Application Autostart tab) or run <code>xfce4-autostart-editor</code>). There, add a new autostarted application with the command being simply <code>xmonad</code> (this of course assumes XMonad is in your path... otherwise, specify the full path to the binary) with whatever name you want. Ensure that the new autostarted application entry you just created is ticked.
   
 
To repeat the warning: '''After creating this, don't exit Xfce until you've finished configuring XMonad and have killed xfwm4!!!'''
 
To repeat the warning: '''After creating this, don't exit Xfce until you've finished configuring XMonad and have killed xfwm4!!!'''
   
==XMonad Hacking==
+
=== XMonad Hacking ===
   
 
[[#Using_XMonad.Config.Xfce|see also, Config.Xfce]]
 
[[#Using_XMonad.Config.Xfce|see also, Config.Xfce]]
Line 90: Line 90:
 
{ manageHook = manageDocks <+> manageHook defaultConfig
 
{ manageHook = manageDocks <+> manageHook defaultConfig
 
, logHook = ewmhDesktopsLogHook
 
, logHook = ewmhDesktopsLogHook
, layoutHook = ewmhDesktopsLayout $ avoidStruts $ layoutHook defaultConfig
+
, layoutHook = avoidStruts $ layoutHook defaultConfig
  +
, handleEventHook = ewmhDesktopsEventHook
  +
, startupHook = ewmhDesktopsStartup
 
, modMask = mod4Mask
 
, modMask = mod4Mask
 
, keys = myKeys
 
, keys = myKeys
Line 102: Line 102:
 
http://gist.github.com/311022 (diff)
 
http://gist.github.com/311022 (diff)
   
== Using XMonad.Config.Xfce ==
+
=== Using XMonad.Config.Xfce ===
 
''with xmonad-contrib-0.8 or greater''
 
''with xmonad-contrib-0.8 or greater''
   
Line 123: Line 123:
 
</haskell>
 
</haskell>
   
=Get XMonad Going!=
+
== Get XMonad Going! ==
   
 
It's now time to ditch Xfce's default Window Manager xfwm4 and replace it with something better (i.e. XMonad). To do so, it's probably easiest to run xfrun4 with Xfce's default key combination Alt-F2 and enter the following:
 
It's now time to ditch Xfce's default Window Manager xfwm4 and replace it with something better (i.e. XMonad). To do so, it's probably easiest to run xfrun4 with Xfce's default key combination Alt-F2 and enter the following:
Line 132: Line 132:
 
If all went well, you'll now find yourself in XMonad!
 
If all went well, you'll now find yourself in XMonad!
   
=That's all folks!=
+
== That's all folks! ==
   
 
Congratulations, you have now successfully configured XMonad and Xfce so that XMonad acts as Xfce's Window Manager! Sample screenshots to come.
 
Congratulations, you have now successfully configured XMonad and Xfce so that XMonad acts as Xfce's Window Manager! Sample screenshots to come.
   
= Note for 4.6.0 =
+
== Specific version notes ==
  +
  +
=== 4.6.0 ===
   
 
The procedure above did not work for me, I had to manually edit the session cache (in ~/.cache/sessions) to remove the entry for xfwm4. This meant removing all the lines with Client0, decrementing the client number for all other clients, and decrementing Count. This needs to be done after logging out so that it isn't clobbered by saving the session on logout.
 
The procedure above did not work for me, I had to manually edit the session cache (in ~/.cache/sessions) to remove the entry for xfwm4. This meant removing all the lines with Client0, decrementing the client number for all other clients, and decrementing Count. This needs to be done after logging out so that it isn't clobbered by saving the session on logout.
   
= Note for 4.6.1 =
+
=== 4.6.1 ===
  +
  +
*I had to delete ~/.cache/sessions directory(while already logged out from any existing Xfce session) for the above solution to work.
  +
  +
*The command <code>killall xfwm4 && xmonad</code> didn't manage to kill xfwm4, it was possible to shut it down in "Settings->Session and Startup->Session" (or through <code>xfce4-session-settings</code>).
  +
  +
=== 4.10 ===
   
I had to delete ~/.cache/sessions directory(while already logged out from any existing Xfce session) for the above solution to work.
+
Overall, the whole article works, except the part about killing xfwm4, which is solved ''almost'' exactly the same as in 4.6.1. Though, you have to be perseverant. I have done the same procedure like 4 times and every time xfwm4 revives at least once. It's even possible that even when you see it killed and does not appear at the session settings dialog, after restarting, it will appear again. After a couple of times (''aka: rinse and repeat'') it will be gone for good.
   
= Problems =
+
== Known Issues ==
   
 
Swapping of two windows does not reflect in the xfce panel. Also the order of the windows in the xfce panel does not match with the order of the windows in xmonad's stack.
 
Swapping of two windows does not reflect in the xfce panel. Also the order of the windows in the xfce panel does not match with the order of the windows in xmonad's stack.

Revision as of 02:23, 20 August 2012

Xmonad-logo-small.png

XMonad

Contents

1 Introduction

This is an updated and hopefully less confusing version of my original blog post located here: X2Monad

Why use Xfce with XMonad?

Whilst XMonad is a truly excellent Window Manager, alone it doesn't offer the full convenience of an entire Desktop Environment, such as the provided menus, all-in-one configuration settings, consistent dialogs, etc. Out of the three main DEs available in Unix-like Operating Systems - Gnome, KDE and Xfce - the latter is often touted as the most "nimble" of the lot. In my own opinion, it is simpler to use than KDE but with more configuration options (and a saner environment) than Gnome.

2 Configuring XMonad to work with Xfce

This guide assumes that you're using at least version 4.4 of Xfce, and have both XMonad and XMonad-Contrib 0.7 installed. First we need to configure Xfce to play nicely, before adding in XMonad.

2.1 Xfce Settings

We're going to utilise Xfce's Session Manager to make sure that xfwm4 (Xfce's default WM) is no longer started. Preferably, it'd be nice if we could have XMonad started this way as well (or even set in a configuration option like with Gnome or KDE), but the former isn't possible until XMonad supports the required Session Management Protocol and the latter isn't possible in Xfce at all.

2.1.1 Backing up your settings

If you're already using Xfce, you may wish to first backup your ~/.config directory. Whilst Xfce isn't the only application/library/etc. to utilise the ~/.config directory to store it's settings, it does so in a few different sub-directories (i.e. in some cases specific applications have their own settings directory), it's easier to backup the whole thing.

Note that as far as I know, it isn't possible to have for the same user both a standard Xfce login and an XMonad Xfce login. Whilst you can have different sessions to determine whether you use XMonad or not, there are some settings - such as the panel layout - that aren't saved on a per-session basis.

2.1.2 Start a new session

For backup purposes in case something goes wrong with your XMonad settings, it is recommended to create a new Xfce session. To do so, open the "Sessions and Startup" option dialog either from the "Settings" section of the Xfce menu, or in Xfce's Settings Manager (xfce-setting-show). Enable the the session chooser and automatic saving of sessions, then logout and log back in again. When the session chooser appears, choose to create a new session.

A word of warning: I found that the session chooser kept crashing Xfce on a freshly installed Xfce-4.4.2. If this happens to you, delete the ~/.config/xfce-session directory.

2.1.3 Setting up Xfce

Open up the Xfce settings manager. There, you can customise Xfce to your hearts content. Note that the following settings dialogs won't be applicable once we start XMonad:

  • Window Manager
  • Window Manager Tweaks
  • Workspaces and Margins

The last option isn't required, as Xfce will happily use XMonad's workspaces.

These options are recommended:

  • Under "Desktop", let Xfce manage the desktop, but under Behaviour set the Desktop Icons to "None". This way, Xfce will control your wallpaper, etc., allowing you to have random lists, different wallpapers for different screens for multi-head setups, etc.
  • The Keyboard settings can be used to set keyboard shortcuts for those multimedia keys (e.g. XF86AudioMute) found on many keyboards, since these types of keys are currently difficult to create shortcuts for in XMonad. Simply setup the various keyevents to these keybindinds for use with xmodmap in ~/.Xmodmap and Xfce will read these on start.
  • Mouse: if you don't have or want to use a mouse, there's a limited type of mouse emulation available where you can use the Numpad arrow keys to move the cursor.
  • For "Preferred Applications", set whichever terminal emulator you plan to use. I find that Xfce's own Terminal application to work quite nicely with XMonad and to resize rather well.

If you so wish, you can now disable the session chooser, though I suggest you leave it enabled until you've successfully managed to login to your Xfce/XMonad environment several times.

2.1.4 Xfce's Panels

If you so wish you can now customize the panels and the plugins on them. This can be safely left to later, however. With XMonad, I typically only have one panel rather than the default two. In terms of panel plugins, I've removed the Task List, but kept the pager: with the EWMH settings in XMonad, Xfce's pager acts as a mini-preview of your various layouts!

2.1.5 Ensure XMonad gets started

Because XMonad doesn't support the session protocol and Xfce is missing an option to specify which Window Manager to use, we must ensure that XMonad is started each time we log in. WARNING!!! Make sure you don't log out and back in again after setting this and before you reach the stage where we kill xfwm4, or else you will have two different Window Managers fighting each other!!! Run Xfce's Autostarted Applications manager (either under the Settings section in the Xfce menu (Menu -> Settings -> Setting Manager -> Sessin and Startup -> Application Autostart tab) or run xfce4-autostart-editor). There, add a new autostarted application with the command being simply xmonad (this of course assumes XMonad is in your path... otherwise, specify the full path to the binary) with whatever name you want. Ensure that the new autostarted application entry you just created is ticked.

To repeat the warning: After creating this, don't exit Xfce until you've finished configuring XMonad and have killed xfwm4!!!

2.2 XMonad Hacking

see also, Config.Xfce

It's now time to customise XMonad. You have a wide variety of Layouts, Hooks, etc. to experiment with. Here are some basic changes that you should make:

  • Replace the old gaps setup with ManageDocks (especially since Gaps are deprecated in the current darcs version of XMonad and won't be present from 0.8 onwards). This also involves changing the keybinding to hide/show panels.
  • Use the EWMH hooks so that Xfce can obtain Workspace information from XMonad and vice versa. This lets the Pager plugin to the panel act as a mini workspace-previewer, and let you choose which workspace to view by clicking on the pager. Note that by using this, the pager will also automatically add/remove workspaces based upon how many workspaces XMonad has.
  • Use mod4 (aka the "Windows" key) as the modifier key. Many applications - including Xfce - use the Alt key for keybindings themselve (e.g. Xfce uses Alt-F2 to show its run dialog).
  • With keybindings, xfce4-session-logout to exit for the Mod-Shift-q keybinding, rather than just exiting XMonad (which will leave Xfce still running).
  • Use Xfce's Terminal as the terminal program.

Here is a minimal ~/.xmonad/xmonad.hs that demonstrates how to do this. Note that it is expected that you copy and edit the sample configuration file to get the remaining keybindings present, or else use something like the EZConfig extension in the Contrib library to selectively add/edit/remove keybindings from the default list. As it stands, this configuration file isn't sufficient, as it doesn't list all the keybindings and in fact won't compile due to the "..." present in the keybinding list.

import XMonad
import qualified Data.Map as M
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
 
myTerminal = "Terminal"
 
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
    [
    ...
    , ((modMask, xK_b), sendMessage ToggleStruts)
    ...
    , ((modMask .|. shiftMask, xK_q), spawn "xfce4-session-logout")
    ...
    ]
 
main = xmonad defaultConfig
              { manageHook = manageDocks <+> manageHook defaultConfig
              , logHook    = ewmhDesktopsLogHook
              , layoutHook = avoidStruts $ layoutHook defaultConfig
              , handleEventHook = ewmhDesktopsEventHook
              , startupHook = ewmhDesktopsStartup
              , modMask    = mod4Mask
              , keys       = myKeys
              }

If you so wish, you can also use xfrun4 or xfce4-appfinder as the program launchers for the Mod-p and Mod-Shift-p keybindings instead of the default dmenu and gmrun.

Here is a complete xmonad.hs and a diff with the template xmonad.hs: http://gist.github.com/311016 (xmonad.hs) http://gist.github.com/311022 (diff)

2.3 Using XMonad.Config.Xfce

with xmonad-contrib-0.8 or greater

Use the following in your ~/.xmonad/xmonad.hs to implement all the suggestions made above. This is a compilable configuration giving you all the basics.

import XMonad
import XMonad.Config.Xfce
 
main = xmonad xfceConfig

You may wish to run ghci or something on your ~/.xmonad/xmonad.hs configuration file to make sure it's correct before moving on to the next section.

With the above configuration, the Meta key still acts as the modMask. I would suggest remapping the modMask to the Super key by the following changes to the above configuration:

main = xmonad xfceConfig
            { modMask = mod4Mask }

3 Get XMonad Going!

It's now time to ditch Xfce's default Window Manager xfwm4 and replace it with something better (i.e. XMonad). To do so, it's probably easiest to run xfrun4 with Xfce's default key combination Alt-F2 and enter the following: killall xfwm4 && xmonad

If all went well, you'll now find yourself in XMonad!

4 That's all folks!

Congratulations, you have now successfully configured XMonad and Xfce so that XMonad acts as Xfce's Window Manager! Sample screenshots to come.

5 Specific version notes

5.1 4.6.0

The procedure above did not work for me, I had to manually edit the session cache (in ~/.cache/sessions) to remove the entry for xfwm4. This meant removing all the lines with Client0, decrementing the client number for all other clients, and decrementing Count. This needs to be done after logging out so that it isn't clobbered by saving the session on logout.

5.2 4.6.1

  • I had to delete ~/.cache/sessions directory(while already logged out from any existing Xfce session) for the above solution to work.
  • The command killall xfwm4 && xmonad didn't manage to kill xfwm4, it was possible to shut it down in "Settings->Session and Startup->Session" (or through xfce4-session-settings).

5.3 4.10

Overall, the whole article works, except the part about killing xfwm4, which is solved almost exactly the same as in 4.6.1. Though, you have to be perseverant. I have done the same procedure like 4 times and every time xfwm4 revives at least once. It's even possible that even when you see it killed and does not appear at the session settings dialog, after restarting, it will appear again. After a couple of times (aka: rinse and repeat) it will be gone for good.

6 Known Issues

Swapping of two windows does not reflect in the xfce panel. Also the order of the windows in the xfce panel does not match with the order of the windows in xmonad's stack.