Created
August 9, 2018 03:07
-
-
Save LSLeary/85563b91ad2b61396ac4e59e6612a4d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XMonad | |
import XMonad.Actions.PerWorkspaceKeys | |
import qualified Data.Map.Strict as M | |
-- | Given config dependent bindings per workspace, produce regular xmonad | |
-- bindings via @bindOn@. Use like e.g. | |
-- | |
-- > main = xmonad $ def { keys = perWkspKeys myKeyBinds <+> keys def } | |
-- > | |
-- > myKeyBinds = \cnf -> | |
-- > [ ("1", wksp1Keys cnf) | |
-- > , ("2", wksp2Keys cnf) | |
-- > , ("" , defKeys cnf) | |
-- > ] where | |
-- > wksp1Keys = \cnf -> | |
-- > [ ((modMask cnf, xK_a), spawn $ terminal cnf) | |
-- > , ((modMask cnf, xK_b), windows W.focusMaster) | |
-- > ] | |
-- > wksp2Keys = \cnf -> | |
-- > [ ((modMask cnf, xK_a), spawn "firefox") | |
-- > ] | |
-- > defKeys = \cnf -> | |
-- > [ ((modMask cnf, xK_b), windows W.focusUp) | |
-- > , ((modMask cnf, xK_c), windows W.focusDown) | |
-- > ] | |
-- | |
perWkspKeys | |
:: (XConfig Layout -> [(WorkspaceId, [((KeyMask, KeySym), X ())])]) | |
-> (XConfig Layout -> M.Map (KeyMask, KeySym) (X ())) | |
perWkspKeys wsKeys = M.map bindOn . foldr wkspAcc M.empty . reverse . wsKeys | |
where | |
wkspAcc (wksp, binds) m = foldr (bindAcc wksp) m binds | |
bindAcc wksp (keypress, action) = | |
M.insertWith (\[nv] ov -> nv:ov) keypress [(wksp, action)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment