Obtaining a beautiful, usable Xmonad configuration

I've spent a lot of time perfecting my workspace; I spend a ton of time at a computer, and so I'm extremely invested in how my tools perform. A window manager is a pretty important tool, and my window manager of choice is Xmonad. Over time, I feel my Xmonad configuration and setup has evolved into something really nice.

Why would someone use a tiling window manager like Xmonad? The short answer is usually efficiency. People spend a lot of time organizing windows, and using their mouse. If you could instead never take your fingers off the keyboard (for the most part,) your efficiency would go up. This won't be true at first as people learn key bindings, but after awhile you become drastically faster at the mundane parts of computing, like switching between windows, or organizing them in different ways. This approach is definitely more minimal, but I'd recommend this if you spend your day in vim, emacs, terminals, or other text-heavy applications. Even Gmail has key bindings so that I don't have to touch my mouse.

Other perks of using Xmonad include things like xmobar, which is surprisingly useful, as it gives tons of information about the state of Xmonad, your system, and your local weather, without being at all intrusive. To start programs, you'll want to use something like dmenu, which auto-completes command names as you type.

If you've never used Xmonad, then this post is intended to help you get going. Otherwise if you're an avid user, then this post will give you a consistent, good looking setup that you'll hopefully find usable and better than the Xmonad defaults.

Here's a screenshot from my workstation:

Screenshot of my Xmonad setup.

I've heard a few comments on how nice everything looks, so I took some time to release the necessary configuration files and scripts in a github project. Why is this nice? Because the color scheme is consistent, the layouts are scalable, and the key combinations are standard. If you use the IR_Black theme for vim or your terminal, you'll notice even more consistency throughout.

I'll run through really quickly how to set this up.

This set of configuration and scripts has the following requirements, but should work with other versions of these requirements (minor modifications required for older versions of Xmonad or xmobar.)

  • xmonad 0.9.1
  • xmonad-contrib 0.9.1
  • xmobar 0.11.1
  • trayer 1.0
  • dmenu 4.0

To install these on an Arch Linux machine, run:

$ sudo pacman -S xmonad xmonad-contrib xmobar trayer dmenu

Next, clone the github repository, and copy the files around to their correct locations:

$ cd
$ git clone git@github.com:vicfryzel/xmonad-config.git
$ mv .xmonad .xmonad.orig
$ mkdir -p ~/.xmonad ~/bin
$ cp -R xmonad-config/xmonad/* ~/.xmonad
$ cp -R xmonad-config/bin/* ~/bin
$ chmod +x ~/bin/*
$ echo "PATH=\$PATH:~/bin" >> ~/.bashrc

Now all you have to do is start Xmonad. The way you do this will vary, but if you're using something like SLiM, then just use this .xinitrc:

xsetroot -cursor_name left_ptr &
xrdb ~/.Xdefaults &
xscreensaver &
~/bin/tray &
gnome-terminal &
gnome-terminal &
google-chrome &
xmonad

...adjusting as needed (e.g. if you don't use Google Chrome or xscreensaver.)

That's it! You should now have a desktop looking like the screenshot above.

If you're new to Xmonad, the key combinations can be daunting, so here are some of them to get you started:

  • Alt+p: Run dmenu. After it's running, start typing a command and hit enter
  • Alt+Shift+Enter: Launch a terminal window
  • Alt+1, Alt+2, ..., Alt+9: Switch to workspace N
  • Alt+w: Switch to the left screen
  • Alt+e: Switch to the right screen
  • Alt+j or Alt+Tab: Switch to the next window
  • Alt+k: Switch to the previous window
  • Alt+Space: Cycle through layouts for the current screen's windows
  • Alt+Enter: Make the currently active window a master window
  • Alt+,: Increase the number of windows in the master area
  • Alt+.: Decrease the number of windows in the master area
  • Alt+m: Switch to the master window
  • Alt+Shift+j: Move the currently active window forward in the layout
  • Alt+Shift+k: Move the currently active window backward in the layout
  • Alt+l: (That's an L.) Make the master area window bigger
  • Alt+h: Make the master window area smaller
  • Alt+Ctrl+l: (That's an L.) Lock the screen with xscreensaver
  • Alt+Left Mouse Button+Drag: Untile the selected window and move it
  • Alt+t: Move the currently active window back into tiling
  • Alt+Right Mouse Button+Drag: Tile and resize the selected window
  • Alt+q: Reload the Xmonad configuration
  • Alt+Shift+q: Exit Xmonad

People are sometimes intimidated by all of these shortcuts and the new style of interface. Remember that the currently active window will be surrounded by a red border. Also, there are a series of layouts you can use. Alt+Space makes cycling between them easy. I recommend you write the key combinations down or print them out, that way if you forget you won't be stuck. For things like watching a movie, just fire up mplayer and hit 'f'. Fullscreen mode works just fine. Otherwise if you don't want to fullscreen and you don't want to tile the video, just Alt+Left Click+Drag, as described above.

Once you're all setup you should:

  • Modify ~/.xmonad/xmobar to show the correct weather for your location
  • Modify ~/.xmonad/xmonad.hs as needed if you don't use xscreensaver, Google Chrome, etc.

For further reading, see:

Let me know if you have any questions, I hope this has made Xmonad better for you!

Update (Jun 28): Mats Rauhala / MasseR has been kind enough to improve the bin/dmenu script to not crash some systems. +1 to him :) I've merged his changes into the github repo mentioned in this post.

Sun, 27 Jun 2010 07:11

From brian about 15 hours later:

Hi. Thanks for writing this! What font are you using in the terminal running vim?

From Vic about 17 hours later:

From Brett 1 day later:

Thanks a lot for this. I actually have a new Thinkpad on the way and planned to to Ubuntu/Xmonad, but I think you’ve convinced me to try Arch.

(I know that isn’t the purpose of this post, but I was really into Gentoo years ago, then switched to OS X, and I’m trying to switch back. Arch looks like a really great rolling release distro)

I hope you don’t mind questions via here or Github about your Xmonad conf. :)

From Vic 2 days later:

Hey Brett,

So I wrote a post about Xmonad and netbooks here: http://www.vicfryzel.com/2009/11/26/getting-arch-linux-fully-working-with-a-samsung-n130-netbook

It has much more breadth than this post, so you’ll probably find this post to be more concise. I definitely recommend a binary distro for a laptop though, and this is coming from a retired Gentoo developer ;)

Personally, I prefer Arch to something more heavyweight like Ubuntu, but primarily because I don’t use the Gnome or KDE desktops.

Thanks, Vic

From Eugen Wissner 25 days later:

Hi, thanks for article! I used xmonad earlier but than decided to try something else, i3. And I liked i3 but later found some bugs. Looked at musca, ratpoison, scrotwm…. installed gnome. And now I reinstalled again my Slackware and want to try xmonad once more. I know that I’m not a fun of functional programming.. Do you use openoffice or other java-programs? Xmonad and OpenOffice.org haven’t any friendship several years with each other. Last time I had problem with the newest versions with focus on office’s floating windows such print or configuration… Can you advise something? Yes, I know, my English isn’t so perfect, but I hope, that understatable, excuse me:)

From Vic Fryzel 25 days later:

Hey Eugen,

I don’t use OpenOffice, I use Google Docs, which render fine in a browser in Xmonad :D It’s nice because there are no floating windows, and thus nothing for Xmonad to manage.

Also, my Xmonad configuration floats floating windows. When an application creates a window, that window has a state that can dictate whether or not a window should be floating. My Xmonad configuration respects that state.

I haven’t tried those window managers you mentioned, but must say that I’m a huge fan of my current setup.

Thanks! Vic

From Kailden about 1 month later:

Thanks for taking the time to put this together. I used this to quickly get xmonad running on Arch…

Comment Obtaining a beautiful, usable Xmonad configuration