Xmonad: install screen and workspace

I am having a problem with this feature working as I expect.

setScreenAndWorkspace i =
  windows (viewOnScreen screenId workspaceId)
  where
    screenId = ((i-1) `mod` numberOfScreens)
    -- workspaceId = show i -- doesn't work for some reason
    workspaceId =
      case i of
        1 -> "1"
        2 -> "2"
        3 -> "3"
        4 -> "4"
        5 -> "5"
        6 -> "6"
        7 -> "7"
        8 -> "8"
        9 -> "9"

I call the function as follows:

myKeys =
  [
    ("M-1"   , setScreenAndWorkspace 1),
    ("M-2"   , setScreenAndWorkspace 2),
    ("M-3"   , setScreenAndWorkspace 3),
    ("M-4"   , setScreenAndWorkspace 4),
    ("M-5"   , setScreenAndWorkspace 5),
    ("M-6"   , setScreenAndWorkspace 6),
    ("M-7"   , setScreenAndWorkspace 7),
    ("M-8"   , setScreenAndWorkspace 8),
    ("M-9"   , setScreenAndWorkspace 9)
  ]

Firstly, show i does not seem to do the same as in case i. I must have misunderstood some basic Haskell thing; if i use show i, it seems that xmonad cannot find any workspace.

The second problem is that the function works, but does not always transmit focus. I need to press the key twice to set the screen, set the workspace and set focus on this workspace.

+5
source share
1 answer

show i , , :

Prelude XMonad> show (1 :: Integer)
"1"
Prelude XMonad> show (1 :: ScreenId)
"S 1"

- drop 2 . show, -

unS (S i) = i
workspaceId = show (unS i)

.

, viewOnScreen , ... , . : " sc. , view i.". , i . ? - :

windows (viewOnScreen screenId workspaceId . viewOnScreen screenId workspaceId)
+2

All Articles