Skip to content

Instantly share code, notes, and snippets.

@henninb
Created August 9, 2021 10:55
Show Gist options
  • Save henninb/d32dfde84832c53102cf9de85197156f to your computer and use it in GitHub Desktop.
Save henninb/d32dfde84832c53102cf9de85197156f to your computer and use it in GitHub Desktop.
xmonad - name the submap keys
import qualified XMonad.Util.NamedActions as NamedActions
import qualified Data.Map as M
keybinds :: XConfig Layout -> [((KeyMask, KeySym), NamedActions.NamedAction)]
keybinds conf = let
subKeys str ks = NamedActions.subtitle str : mkNamedKeymap conf ks
in
subKeys "Scratchpads"
[
("M-S-o", NamedActions.addName "submap" $ submap . M.fromList $
[
((0, xK_s), namedScratchpadAction scratchPads "spotify-nsp")
, ((0, xK_d), namedScratchpadAction scratchPads "discord-nsp")
, ((0, xK_t), namedScratchpadAction scratchPads "tmux-nsp")
])
]
@henninb
Copy link
Author

henninb commented Aug 9, 2021

I think the code would look similar to the code below.

,("M-S-o", submapName $ mkNamedKeymap conf
    [("s", addName "Spotify" $ scratchPads "spotify-nsp")
    ,("d", addName "Discord" $ scratchPads "discord-nsp")
    ,("t", addName "Tmux" $ scratchPads "tmux-nsp")
    ])

@henninb
Copy link
Author

henninb commented Aug 9, 2021

Replace the plain submap. M.fromList bit with the special XMonad.Util.NamedActions.submapName (it already takes a list) to get it to propagate the action descriptions "upwards".

https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Util-NamedActions.html#v:submapName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment