skyb.us

Switching to XMonad

I'm learning that the more work habits I adopt from a particular coworker and friend, the more efficient I am (aside: The last one I adopted was a monthly subscription to Odwalla bars at work). I've looked lustfully over at his xmonad desktop more than once before. The basic idea is:

  • I should NEVER see my desktop background--I want the window manager to configure the window sizes so everything is optimized for maximum space
  • Using the mouse to move between windows and tasks sucks! I want to use my keyboard

I'd given up after a couple dives, due to the learning curve--not the learning curve of the environment, but the learning curve necessary to configure it correctly in order to be efficient. This time, after a couple of labyrinthine Carnot paths that ended up being Work=0, I've come up with a much shorter transition plan for those interested in taking a plunge.

So, assumptions are: your average Ubuntu Gnome desktop environment. I have two monitors, so I talk about that case, but having one or three has the same instructions.

  1. $ sudo aptitude install xmonad libghc6-xmonad-dev libghc6-xmonad-doc scrot
  2. Install your xmonad config script.

    This is the scariest step really. You can look at all your options later, but I found the current defaults mostly work.
    The damn thing is in Haskell, and it seems they've refactored the API several times, so a lot of sections of published config scripts on the web will NOT work.
    Start out with mine, which should get you started, anyway.

    import XMonad
    import XMonad.Hooks.ManageDocks
    import XMonad.Hooks.EwmhDesktops
    import qualified XMonad.StackSet
    import XMonad.Util.EZConfig
     
    main = xmonad $ defaultConfig
                    { manageHook = manageDocks <+> manageHook defaultConfig
                    , logHook    = ewmhDesktopsLogHook
                    , layoutHook = ewmhDesktopsLayout $ avoidStruts
                                     $ layoutHook defaultConfig,
              modMask = mod4Mask
            
                    }
        
            `additionalKeysP`
            [("M-", windows XMonad.StackSet.swapUp)
                    ,("M-", windows XMonad.StackSet.swapDown)
                , ("M-f", spawn "firefox")
                , ("M-o", spawn "emacs")
                ]
    

    Two things you might want to change:

    • Note that I have my text-editor, Emacs as Mod-o. You might want to change this to gedit or vi, or whatever
    • Later, you can add other keyboard shortcuts (or even sequences, like 'M-x f')

  3. Put that config file in ~/.xmonad/xmonad.hs.
    • If you start hacking it, you can run $ ghci ~/.xmonad/xmonad.hs to make sure it's valid.
  4. Now edit/create a file ~/.gnomerc with the single line export WINDOW_MANAGER=xmonad.
    • NOTE: If you give up, or don't like XMonad, just remove that line, and logout/login again!
  5. If you have two monitors, one thing that I did more easily before the switch was adding a new GPanel to the top of the second screen, and adding a second Workspace Switcher widget, so both screens have one. This widget is non-ideal for how xmonad thinks of screens, but until something better comes along....
  6. OK, you're ready to try XMonad out! Just logout and log back in (or restart, if you want to wait an extra minute).

Getting around

  • Print out this cheat sheet
  • Read the Guided Tour, and if you have two monitors, The idea of how screens and workspaces relate is important. I think the rough order of important shortcuts (the Windows key is the 'Mod' or 'M' key here, btw):
    • Where is your attention: M-w (left monitor), M-e (right monitor); M-j, M-k (next/prev app on monitor)
    • My current focus needs more/less space: M-<space> (cycle through different window configurations); M-h, M-l (increase/decrease window/app size);
    • Switch workspace of current monitor to: M-[1-9]
    • Send current window/app to workspace #: M-<shift>-[1-9]
    • Give me a new.... M-<shift>-<Enter> (terminal) M-o (editor); M-f (browser)
    • Move current window/app to different positions in current layout: M-<Up>, M-<Down>
  • Figure out how you're going to organize your desktop. I'm still working on this, but the main one is that Email and IM contact-list is on workspace 5. IM talk is on workspace 1, with terminal.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <i> <b> <br> <blockquote>
  • Lines and paragraphs break automatically.

More information about formatting options

You can change the default for this field in "Comment follow-up notification settings" on your account edit page.