XMonad - Clickable workspaces (dzen2)

XMonad – Clickable workspaces (dzen2)

One feature DWM has which is missing in XMonad is the clickable workspaces in status bar. There is a very good reason for this, which is that statusbars in XMonad are external applications i.e. XMobar and Dzen2.

To achieve clickable workspaces in XMonad with Dzen2 the following is needed:

Include these modules in your xmonad.hs:

import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import Data.List

Comment out your current workspace listing and enter following instead:

myWorkspaces            :: [String]
myWorkspaces            = clickable . (map dzenEscape) $ ["1","2","3","4","5"]

  where clickable l     = [ "^ca(1,xdotool key alt+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
                            (i,ws) <- zip [1..] l,
                            let n = i ]

If you have any redirects in your ManageHook change them accordingly:

,className =? "Firefox"  --> doF (W.shift (myWorkspaces !! 1))

Reference: McManiac @ http://bbs.archlinux.org/viewtopic.php?id=40637&p=8