xfce + xmonad on Gentoo Linux

| | Comments (1)

xfce4 is a lightweight (compared to Gnome and KDE) which I happen to love, as it still provides nice theming, a well-done panel system and some interesting goodies. The window manager (xfwm4) is not handy as others. xmonad is, however, a great one, in particular: tiling, highly customizable and... written and extendable in Haskell!!! So, it makes up for a good replacement.

I decided to change xfce's window manager and use xmonad. The thing required a few steps in order to begin working properly. Here's a tutorial which presumes you use the following software versions:

xfce 4.6.1
xmonad 0.8.1
gmrun 0.9.2
dmenu 4.0

This is a screenshot of how it's going to look like.

I also assume you have a working xfce4 installation and you're able to login to the xfce desktop with an account (by the way, I suggest slim as login manager).

First of all, you need to emerge xmonad (after unmasking it in /etc/package.keywords):

emerge -av xmonad xmonad-contrib

xfce configuration

The first thing is to properly configure xfce. My suggestion is to open the Desktop settings dialog box and, in the Icons tab, uncheck all default icons: it's a tiling window manager, and having icons around will only leave a box containing them which is going to look weird. You're not migrating to a tiling window manager to use desktop icons, aren't you? ;-)

Switching from xfwm4 to xmonad is a bit tricky, as xfce4 doesn't support (like Gnome and KDE do) configuring the window manager at all, and xmonad doesn't support the session protocol (so we must ensure that xmonad is started every time we log in). So, just login with your account, open a terminal and then terminate xfvwm4 while launching xmonad:

kill `pidof xfvm4` && xmonad &

The window manage should be replacing (you'll notice your windows tiling). At this point exit xfce4 saving the session: this will ensure xmonad is started again when you log back in. Problem is xfce will also try to start xfvwm4: to avoid this you have to locate you session file in ~/.cache/sessions and remove the entry for xfvwm4.

At this point you should be able to login again and xmonad will be your new default window manager.

xmonad configuration

xmonad needs a some tweaking to play well with xfce, and also to be more usable on its own.

Looking into you ~/.xmonad directory you'll find a xmonad.hs file which is used to compile xmonad (the xmonad-x86_64-linux binary in the same directory, with the name changing depending on your arch) when starting it for the first time. The configuration file is in Haskell, so it might look a bit weird if you haven't seen the language before. The instruction given below might vary if you xmonad.hs is a bit different, or if you already customized it somehow.

First of all, we need to ensure xmonad properly manages the xfce4 panels (I have one, at the bottom), by placing them where you expect them to be, by making them visible in all workspaces and by avoid application windows to overlap them. Add this line after the other import ones:

import XMonad.Hooks.ManageDocks

Locate the:

myLayout = tiled ||| Mirror tiled ||| Full

and change it to:

myLayout = avoidStruts(tiled ||| Mirror tiled ||| Full) 

Then locate:

myManageHook =  composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore ]

and replace it with the following code. It's actually a small change but I chose to create an extra variable for the sake of clarity.

stockManageHook =  composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore ]
myManageHook =  manageDocks <+> stockManageHook 

Now that we ensured the panels get a proper placement, we'd better change the default xmonad mod key: the default left Alt conflicts with the shortcuts of many applications, including xfce terminal, firefox, and others. Luckily, we have an otherwise almost useless "Windows start" key on the left of the keyboard; to use that as mod key find this line:

myModMask       = mod1Mask 

and change it to:

myModMask       = mod4Mask 

I suggest you delete the binary inside the .xmonad directory before logging back in, in order to ensure it's compiled again.

additional software

In its default configuration, xmonad provides key binding for a couple of useful softwares.

gmrun (mod+shift+p) opens a small text box where you can enter the name of a command to launch. You can also use xfce's own "Run program..." feature of course.

dmenu(mod+p) opens a nice menu bar (at the top by default) which lists what you have in /usr/bin (by default) and can be used to launch programs by just typing a few letters and navigating the list. Very handy.

Well, that's it: you should have everything working now. Exercise your hands and fingers for xmonad. ;-)

1 Comments

Thanks for writing this up.

With new xmonad-0.9 release, more people may be looking for xfce integration instructions. It will be great to be able to point them toward your blog, since the XMonad.Confg.Xfce and xmonad wiki instructions are, "Maintainer Wanted" and have not been updated in a long time.

http://haskell.org/haskellwiki/Xmonad/Using_xmonad_in_XFCE

Michele, it would be great if you could check to see if the xmonad wiki entry has any bad information or could be improved in any way. There are links at the top of the page to get a wiki account. Or if you prefer to just have someone else do it, please let someone know on IRC, #xmonad on freenode.

Thanks!

Leave a comment

Perl IronMan

My current status is:
Stone Man

About this Entry

This page contains a single entry by Michele Beltrame published on August 13, 2009 10:46 AM.

Possibile giornata su Moose con Dave Rolsky a Pisa in Ottobre 2009 was the previous entry in this blog.

Sparse thoughts on YAPC::EU 2009, Lisbon is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Pages

Powered by Movable Type 4.23-en