I’ve been following the XMonad project recently. For those of you who don’t know what XMonad is, I recommend you have a browse through the home page and it’s Wikipedia article. I’ve been planning on playing with XMonad for a while, though my initial plans were to wait till I bought myself a new über box to use in conjunction with my laptop. However, I decided to delay purchasing a new computer (because I couldn’t decide which CPU to get, not due to lack of cash) but couldn’t delay using XMonad any further.
Square that X!
One problem I’ve always had with all the XMonad screenshots I’d seen was that to my mind, dzen and xmobar look rather ugly to me, though this could be due to everyone loving dark colours for their setup. Personally, I much prefer a live graphical image of the various meters, etc. that I have residing on my panels.
Since I heard that KDE 4.0 was going to be released soon (this was around the 9th of January when I started this), I thought I’d do one better than Spencer Janssen’s usage of kicker with XMonad and actually use the full KDE environment with XMonad replacing kwin. After all, if it’s possible to integrate XMonad into Gnome, doing it with KDE should be possible. However, I got sick of waiting for the release date and decided to install version 3.5.8 instead.
Whilst I prefer KDE to Gnome, in the end I couldn’t stand using KDE either. So I decided to go back to using Xfce 4.4, which I’ve been using since one of its betas. I quite like Xfce: for a Desktop Environment, it’s rather responsive and fast. My only complaints is that sometimes it’s too simplistic: so to change an autostart application I have to manually edit the file rather than using the GUI; and some Gnome-oriented apps keep dumbing down. So I decided to combine Xfce with XMonad to form X2Monad (though it turns out gour on #gentoo-haskell has been doing this for a while already without telling anyone).
So why use a DE?
First of all, why not? :p Sure, most people use XMonad in a very minimalistic-environment. However, I’ve become used to having an overall set of applications that integrate nicely, with a consistent manner for configuration (including setting the theme, etc.). Furthermore, I quite like the Xfce panels and the plugins for them (more so than kicker & co.).
Secondly, I’ve found that DEs have better menus and have them by default. Whilst I don’t use the menu often, it is often useful to get an idea of what’s installed and what the name of a particular program you have is (I’ve done this before where I installed something, decided I didn’t like it but couldn’t remember what it was called to uninstall it).
Finally, I want to use a DE with XMonad because I can… that’s the beauty of FLOSS! Especially when you bring in Gentoo’s USE-flags, etc.
Getting the required packages
I use Gentoo, so obviously this section will be distro-centric. However, you can probably find the equivalent package in whatever distribution you use and/or build it from source yourself.
You obviously need Xfce 4.4 and XMonad installed (along with XMonad-Contrib, the user-contributed libraries for XMonad). I’ve been using the darcs (i.e. development) version of the latter two, and so far haven’t had any problems (despite updating at least once a day). To get the ebuilds for these in Gentoo, you first need to access the Haskell Overlay. This is available via layman, but requires darcs to be installed (if you don’t already have ghc – the Glorious Glasgow Haskell Compiler – installed, consider emerging it with the “binary” USE flag, which will install a customised Gentoo ghc binary for you).
So, assuming you’ve got the overlay installed (if not, you can probably just use the non darcs packages in the official tree, but YMMV: in particular, these instruction require at least version 0.5 of XMonad), you’ll need to install the following packages:
- xfce4 (optionally with xfce4-extras)
The latter two will probably require adding them to your package.keywords file first before being able to emerge them.
The USE flags for these don’t really matter, though enabling the “doc” USE flag may be helpful (for the two XMonad packages, this installs the haddock docs which are also available on the homepage).
Before being able to use XMonad together with Xfce, we first need to setup Xfce. We’re going to use Xfce’s session management for the most part to get rid of xfwm4 (Xfce’s default window manager) and keep the rest of Xfce happy.
First of all, particularly if you’re already using Xfce, backup your ~/.config directory, as well as anywhere else you might have Xfce settings lying around. This is important in particular to restore your panel settings if you decide to stop using XMonad.
The Settings Manager
Now open up Xfce’s settings manager (you can get this either from the menu, the prompt or else by running xfce-setting-show). Under “Sessions and Startup”, enable choosing of sessions and auto-saving of sessions. Now, to try and ensure we’ve got a backup session going that still works, logout and log back in again, this time choosing to create a new session.
Open up the settings manager again. Under “Desktop”, you can choose to disable desktop management. When Xfce manages your desktop, it does three things:
- Setting/Changing the wallpaper
- Desktop Icons (stored in your ~/Desktop folder)
- Ability to get popup-menus (including the normal program menu and a window listing menu) by clicking on the desktop.
In reality, unless you use some of the more “innovative” of the layouts, you’re not likely to see the desktop at all (at least not after you’ve opened a program on that particular workspace). I’ve still got it enabled at the moment, but that’s only because I’m slowly paring down the junk I’ve saved onto the Desktop.
Edit: There’s a setting in Desktop that enables you to disable icons on the desktop. Now I just use xfdesktop to set my wallpaper.
Under “Preferred Applications”, set the preferred Terminal Emulator (under Utilities) under whatever terminal program you’re going to use. I’m currently using the (XMonad-) recommended rxvt-unicode (AKA urxvt), though Xfce’s Terminal seems to work nicely as well. You can also set your preferred browser and mail client. These settings are used for when Xfce has to open one of these applications (and what the default panel shortcut buttons open up), so these settings may be useless to you if you open everything yourself.
You can safely ignore the “Window Manager” and “Window Manager Tweaks” sections, as we’re not going to be using xfwm4 for much longer. The “Workplaces and Margins” settings are also ignorable, as Xfce seems to quite happily use XMonad’s settings for number of workplaces, etc.
IF you want, you can now disable Xfce’s session manager asking you which session you want to start with. However, I would leave it for now in case you make a mistake and need to get back to your saved backup session. Apart from that, we’re finished with the settings manager.
If you want, you can now setup your panels how you want them. Note that you can leave this to later if you wish (as I did). However, as far as I can tell it is not possible to have panels configured on a per-session basis, so any changes you make now are those you’re stuck with (which is why you should have backed up your ~/.config folder). In particular, I decided to remove items such as the Task List. Keep the pager, however… it plays nicely with XMonad to provide you with mini-previews of what applications are on which workspace as well as their layout (however, you can’t as yet switch workspaces via the pager).
For the most part, the instructions on how to setup XMonad to play nicely with Xfce are the same as those for Gnome. These settings let the gaps for the panels be automatically detected and created, and for the pager in the panel to get information on XMonad’s workspaces.
However, I recommend that rather than starting from scratch, that you copy over the the sample xmonad.hs configuration file into ~/.xmonad/xmonad.hs and edit that instead. There is one item on that page that is missing, however: thanks to rob| on #xmonad, the following line in the sample xmonad.hs:
, ((modMask , xK_b ), modifyGap (\i n -> let x = (XMonad.defaultGaps conf ++ repeat (0,0,0,0)) !! i in if n == x then (0,0,0,0) else x))
should be replaced with:
,((modMask , xK_b ), sendMessage ToggleStruts)
This allows the mod-b behaviour to work properly with the struts setup.
Another change you might want to make is customising the modMask used: there are some Xfce key-combinations (e.g. Alt+F2) that are still handy and mightn’t work properly if XMonad uses the left Alt key as its modMask (not to mention other programs like Emacs that use Alt). I’m using the Windows key at the moment (which is mapped to mod4mask). I’d like to use the right Alt key, but I’ve got to play further with xmodmap to get it working.
Getting rid of xfwm4
Now we need to get rid of xfwm4 and startup XMonad. In a prompt or using xfrun4 (defaults to Alt+F2), enter the following:
killall xfwm4 && xmonad
You might have to hit mod-q to get your customised layout to show up, but otherwise you should now have XMonad working!
Keeping it working
Unfortunately, whilst the session manager can keep xfwm4 killed, XMonad as yet isn’t compatible with session managers. To get XMonad to start each time we log in, we can use Xfce’s autostart feature: open it from the menu of by running xfce4-autostart-editor, and add in an XMonoad entry (the run command merely needs to be “xmonad” without the quotes). That should now be it!
Of course, you can still change other Xfce settings, and edit the plugins in the panel. If you can successfully log in and out, then you can also disable choosing which session you want to use.
The proof is in the screenies
Here are two screenshots of my system: one before I used XMonad (note that this was a while ago, so some settings might have changes slightly):
(In case you’re wondering, the IRC conversation here involved me stating that the new aMSN looked rather nice, whilst everyone else immediately dismissed it for using tcl/tk, though after posting that screenshot they grudgingly half-agreed with me.)
And one after:
(Both of these thumbnails link to the full size images.)
Now, my XMonad configuration isn’t perfect (I’m still playing with layouts, auto-floating stuff, etc.)…. but I’m already quite happy with it. Note especially the pager in the second screenshot: I added in the fifth workspace to XMonad just to see what happened, and after restarting XMonad the extra workspace instantly appeared in the pager! Now that’s cool!
Edit: Xfce’s desktop settings.