Search code examples
xmonad

How to switch xmonad workspace and notify the current workspace's tag or name under full screen without bar?


I connfig the xmonad workspaces as follows

myWorkspaces = map show [1..20 :: Int]

[((mod4Mask .|. m, k), windows $ f i)
| (i, k) <- zip myWorkspaces ([xK_1 .. xK_9] ++ [xK_0] ++ [xK_F1 .. xK_F10])
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask), (copy, mod3Mask)]
]

And I want to use notify-send shell command to show the current workspace number when switch to a certain workspace.

So how to define a function to greedyView the workspace and show the notification?


Solution

  • ok, I solved the problem by myself.

    [((mod4Mask .|. m, k), workspaceHint f i)
        | (i, k) <- zip myWorkspaces ([xK_1 .. xK_9] ++ [xK_0] ++ [xK_F1 .. xK_F10])
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask), (copy, mod3Mask)]
        ]
    
    notifyWSHint :: String -> X()
    notifyWSHint index = spawn $ "notify-send -t 500 \"workspace: " ++ index ++ "\""
    
    workspaceHint f i = do
      windows $ f i
      notifyWSHint i