Home > Software engineering >  How do I get list of workspaces on monitor x with IndependentScreens
How do I get list of workspaces on monitor x with IndependentScreens

Time:12-16

I've got 2 monitors of different sizes, one of witch is placed vertically, and I'd like them to have different layouts by default

I'm using XMonad.Layout.IndependentScreens to assign each monitor it's own set of workspaces

I have found a library that does approximately what I need XMonad.Layout.PerWorkspace

With that, I defined 2 monitor layouts that I will be using:

  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

So now I'm trying to use them on layout hook, together with workspacesOn function from IndependentScreens

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

This fails with following error:

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
    |           

Now I'm confused, because that function is in the documentation, and I clearly included the reference to IndependantStreens, it's in the error message

What is the issue with the code above, and how do I get this to work?

CodePudding user response:

Somewhere in your config, you have written something like:

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

You can get a list of the workspaces on a specific screen with marshall. The workspaces on screen 0 are map (marshall 0) ["a", "b", "c"] and similarly for screen 1. You should probably separate out the list of virtual workspaces into its own definition. So:

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

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

...
    workspaces = withScreens 2 virtualWorkspaces
  • Related