14

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.

bitmask
  • 32,434
  • 14
  • 99
  • 159
  • @AndrewC: No it's not generated from the strings. I can say "foo" instead of "1" and that will only influence what is displayed as the name of the workspace. Note that I use Unicode characters to depict what some of the workspaces are dedicated for. – bitmask Jan 02 '15 at 14:08

3 Answers3

15

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)
bitmask
  • 32,434
  • 14
  • 99
  • 159
  • 2
    Thanks! To make your examples work, I also needed `import qualified XMonad.StackSet as W` and had to replace both occurrences of `myModMask` to `modm`. I'm not sure where `modm` is defined but it matched the pattern used in other key bindings. – Robie Basak Mar 23 '16 at 01:11
1
-- | The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
--
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
--
workspaces :: [WorkspaceId]
workspaces = map show [1 .. 9 :: Int]

Modify the length of the list in Config.hs

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
1

Another way is dynamic workspaces. Add

import XMonad.Actions.DynamicWorkspaces
import XMonad.Actions.CopyWindow(copy)

to your xmonad.hs file and add

, ((modm, xK_v), selectWorkspace myXPConfig)

to the keybindings in that file. Then pressing mod+v lets you switch to a workspace by name or create it if it doesn't exist.

Andrew
  • 1,041
  • 1
  • 16
  • 24