Search code examples
haskelldesktopxmonad

How can I have more than 9 workspaces in xmonad?


I can change the names of workspaces, and presumably simply add more by changing this conststant:

myWorkspaces = ["1","2","3⌂","4","5","6","7✉","8☺","9♫"]

If I add something to the array, there will be more workspaces, but how do I keybind them? Mod-1 through Mod-9 are the default but I can't find documentation for how to change that default.


Solution

  • I found the answer buried in this example configuration and together with the key names list, it looks like the following:

    Defining a tenth workspace:

    myExtraWorkspaces = [(xK_0, "0"),(xK_minus, "tmp"),(xK_equal, "swap")]
    
    myWorkspaces = ["1","2","3⌂","4","5","6","7✉","8☺","9♫"] ++ (map snd myExtraWorkspaces)
    

    Then the key binding looks like this:

    myKeys = 
          [ -- ... some more keys ...
          ] ++ [
            ((myModMask, key), (windows $ W.greedyView ws))
            | (key,ws) <- myExtraWorkspaces
          ] ++ [
            ((myModMask .|. shiftMask, key), (windows $ W.shift ws))
            | (key,ws) <- myExtraWorkspaces
          ]
    

    In this example the slash key is used, but any other key from the list above can be used instead.

    And finally:

    main = do
     xmonad $ config {
               workspaces = myWorkspaces
            } `additionalKeys` (myKeys)