我怎样才能在 xmonad 中拥有超过 9 个工作区?

How can I have more than 9 workspaces in xmonad?

我可以更改工作区的名称,大概可以通过更改此常量来简单地添加更多名称:

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

如果我在数组中添加一些东西,将会有更多的工作空间,但我如何对它们进行键绑定? Mod-1 到 Mod-9 是默认设置,但我找不到有关如何更改该默认设置的文档。

-- | 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]

修改Config.hs中列表的长度

我在this example configuration and together with the key names list中找到了答案,它看起来像下面这样:

定义第十个工作区:

myExtraWorkspaces = [(xK_0, "0"),(xK_minus, "tmp"),(xK_equal, "swap")]

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

然后键绑定如下所示:

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

在此示例中使用了斜线键,但也可以使用上面列表中的任何其他键。

最后:

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

另一种方式是dynamic workspaces。 添加

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

到您的 xmonad.hs 文件并添加

, ((modm, xK_v), selectWorkspace myXPConfig)

到该文件中的键绑定。 然后按 mod+v 可以按名称切换到工作区,如果不存在则创建它。