1

我有 2 个不同尺寸的显示器,其中一个是垂直放置的,我希望它们默认有不同的布局

XMonad.Layout.IndependentScreens用来为每个监视器分配它自己的一组工作区

我找到了一个库,可以满足我的需要XMonad.Layout.PerWorkspace

有了这个,我定义了 2 个我将使用的监视器布局:

  where
     -- default tiling algorithm partitions the screen into two panes
     tiled   =  (Tall nmaster delta ratio) -- here, we can use `magicFocus`, but it creates several inconviniences

     -- The default number of windows in the master pane
     nmaster = 1

     -- Default proportion of screen occupied by master pane
     ratio   = 2/3

     -- Percent of screen to increment by when resizing panes
     delta   = 3/100

verticalLayout = Mirror tiled ||| tabbed shrinkText myTabConfig ||| noBorders Full  ||| tiled
  where
     -- default tiling algorithm partitions the screen into two panes
     tiled   =  (Tall nmaster delta ratio) -- here, we can use `magicFocus`, but it creates several inconviniences

     -- The default number of windows in the master pane
     nmaster = 1

     -- Default proportion of screen occupied by master pane
     ratio   = 2/3

     -- Percent of screen to increment by when resizing panes
     delta   = 3/100

所以现在我试图在布局挂钩上使用它们,以及来自 IndependentScreens 的 workspacesOn 函数

        layoutHook         = smartBorders . avoidStruts $
            onWorkspaces (workspacesOn 0) myLayout $
            onWorkspaces (workspacesOn 1) verticalLayout

这失败并出现以下错误:

xmonad.hs:447:27: error:
    • Variable not in scope: workspacesOn :: Integer -> [WorkspaceId]
    • Perhaps you meant one of these:
        ‘workspaces'’ (imported from XMonad.Layout.IndependentScreens),
        ‘workspaces’ (imported from XMonad),
        ‘W.workspaces’ (imported from XMonad.StackSet)
    |
447 |             onWorkspaces (workspacesOn 0) myLayout $
    |                           ^^^^^^^^^^^^

xmonad.hs:448:27: error:
    • Variable not in scope: workspacesOn :: Integer -> [WorkspaceId]
    • Perhaps you meant one of these:
        ‘workspaces'’ (imported from XMonad.Layout.IndependentScreens),
        ‘workspaces’ (imported from XMonad),
        ‘W.workspaces’ (imported from XMonad.StackSet)
    |
448 |             onWorkspaces (workspacesOn 1) verticalLayout
    |           

现在我很困惑,因为该函数在文档中,并且我清楚地包含了对 IndependantStreens 的引用,它在错误消息中

上面的代码有什么问题,我该如何让它工作?

4

1 回答 1

1

在您的配置中的某处,您编写了如下内容:

workspaces = withScreens 2 ["a", "b", "c"]

您可以使用 获取特定屏幕上的工作区列表marshall。屏幕 0 上的工作区map (marshall 0) ["a", "b", "c"]与屏幕 1 类似。您可能应该将虚拟工作区列表分离到自己的定义中。所以:

virtualWorkspaces = ["a", "b", "c"]

    ... (map (marshall 0) virtualWorkspaces) ...
    ... (map (marshall 1) virtualWorkspaces) ...

...
    workspaces = withScreens 2 virtualWorkspaces
于 2021-12-15T01:06:17.447 回答