diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2009-12-20 20:07:39 +0100 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2009-12-20 20:07:39 +0100 |
commit | 1c05da6f3230be66bc62184a72526338c1757877 (patch) | |
tree | d4280d8be0f5ecc0814dd34c87d5f176d0273d0c /XMonad | |
parent | 6cad66e67a68f2f57c0faf159a6e0412b67f55e0 (diff) | |
download | XMonadContrib-1c05da6f3230be66bc62184a72526338c1757877.tar.gz XMonadContrib-1c05da6f3230be66bc62184a72526338c1757877.tar.xz XMonadContrib-1c05da6f3230be66bc62184a72526338c1757877.zip |
In D.Extending note how <+> can be used with keybindings.
Ignore-this: ebea8ef8a835ed368fa06621add6519f
darcs-hash:20091220190739-1499c-bb3eb7e6a4caec3ffebb240d500d464b7107b027.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Doc/Extending.hs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/XMonad/Doc/Extending.hs b/XMonad/Doc/Extending.hs index b57bc2e..749b72e 100644 --- a/XMonad/Doc/Extending.hs +++ b/XMonad/Doc/Extending.hs @@ -977,7 +977,7 @@ module, before starting we must first import this modules: For instance, if you have defined some additional key bindings like these: -> myKeys conf@(XConfig {XMonad.modMask = modm}) = +> myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList > [ ((modm, xK_F12), xmonadPrompt defaultXPConfig) > , ((modm, xK_F3 ), shellPrompt defaultXPConfig) > ] @@ -985,13 +985,19 @@ these: then you can create a new key bindings map by joining the default one with yours: -> newKeys x = M.union (keys defaultConfig x) (M.fromList (myKeys x)) +> newKeys x = myKeys x `M.union` keys defaultConfig x Finally, you can use @newKeys@ in the 'XMonad.Core.XConfig.keys' field of the configuration: > main = xmonad $ defaultConfig { keys = newKeys } +Alternatively, the '<+>' operator can be used which in this usage does exactly +the same as the explicit usage of 'M.union' and propagation of the config +argument, thanks to appropriate instances in "Data.Monoid". + +> main = xmonad $ defaultConfig { keys = myKeys <+> keys defaultConfig } + All together, your @~\/.xmonad\/xmonad.hs@ would now look like this: @@ -1006,11 +1012,9 @@ All together, your @~\/.xmonad\/xmonad.hs@ would now look like this: > import XMonad.Prompt.XMonad > > main :: IO () -> main = xmonad $ defaultConfig { keys = newKeys } +> main = xmonad $ defaultConfig { keys = myKeys <+> keys defaultConfig } > -> newKeys x = M.union (keys defaultConfig x) (M.fromList (myKeys x)) -> -> myKeys conf@(XConfig {XMonad.modMask = modm}) = +> myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList > [ ((modm, xK_F12), xmonadPrompt defaultXPConfig) > , ((modm, xK_F3 ), shellPrompt defaultXPConfig) > ] @@ -1034,10 +1038,10 @@ For example, suppose you want to get rid of @mod-q@ and @mod-shift-q@ to define @newKeys@ as a 'Data.Map.difference' between the default map and the map of the key bindings you want to remove. Like so: -> newKeys x = M.difference (keys defaultConfig x) (M.fromList $ keysToRemove x) +> newKeys x = keys defaultConfig x `M.difference` keysToRemove x > -> keysToRemove :: XConfig Layout -> [((KeyMask, KeySym),X ())] -> keysToRemove x = +> keysToRemove :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) +> keysToRemove x = M.fromList > [ ((modm , xK_q ), return ()) > , ((modm .|. shiftMask, xK_q ), return ()) > ] |