diff options
author | Valery V. Vorotyntsev <valery.vv@gmail.com> | 2007-11-13 21:18:52 +0100 |
---|---|---|
committer | Valery V. Vorotyntsev <valery.vv@gmail.com> | 2007-11-13 21:18:52 +0100 |
commit | 64cf4f348e66c4513983b5fd06c257714079a9e0 (patch) | |
tree | 0a31c4e41345e33de7a8b38d9759a4c679fa711c | |
parent | 8566cbd9d2c76fd7582637c66b000c5d5d874a90 (diff) | |
download | XMonadContrib-64cf4f348e66c4513983b5fd06c257714079a9e0.tar.gz XMonadContrib-64cf4f348e66c4513983b5fd06c257714079a9e0.tar.xz XMonadContrib-64cf4f348e66c4513983b5fd06c257714079a9e0.zip |
CustomKeys.hs (customKeysFrom): new function
Update third-party configuration to fit your key preferences.
Extended documentation.
darcs-hash:20071113201852-ae588-fffe70dda24c09102b39e3a05cd6f9fd6f1c7f1f.gz
-rw-r--r-- | XMonad/Config/CustomKeys.hs | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/XMonad/Config/CustomKeys.hs b/XMonad/Config/CustomKeys.hs index 8146af8..e86ce09 100644 --- a/XMonad/Config/CustomKeys.hs +++ b/XMonad/Config/CustomKeys.hs @@ -12,9 +12,10 @@ -------------------------------------------------------------------- module XMonad.Config.CustomKeys ( - -- * Usage - -- $usage - customKeys + -- * Usage + -- $usage + customKeys + , customKeysFrom ) where import XMonad @@ -46,16 +47,26 @@ import qualified Data.Map as M -- > , ((mod1Mask, xK_Up ), spawn "amixer set Master 1+") -- > ] --- | XXX comment me (no tautology please) -customKeys :: (XConfig Layout -> [(KeyMask, KeySym)]) -- ^ unused shortcuts - -> (XConfig Layout -> [((KeyMask, KeySym), X ())]) -- ^ new bindings +-- | Customize 'XMonad.Config.defaultConfig' -- delete needless +-- shortcuts and insert the ones you use. +customKeys :: (XConfig Layout -> [(KeyMask, KeySym)]) -- ^ shortcuts to delete + -> (XConfig Layout -> [((KeyMask, KeySym), X ())]) -- ^ key bindings to insert -> XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) -customKeys = (runReader .) . customize +customKeys = customKeysFrom defaultConfig -customize :: (XConfig Layout -> [(KeyMask, KeySym)]) +-- | General variant of 'customKeys': customize key bindings of +-- third-party configuration. +customKeysFrom :: XConfig l -- ^ original configuration + -> (XConfig Layout -> [(KeyMask, KeySym)]) -- ^ shortcuts to delete + -> (XConfig Layout -> [((KeyMask, KeySym), X ())]) -- ^ key bindings to insert + -> XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) +customKeysFrom conf = (runReader .) . customize conf + +customize :: XConfig l + -> (XConfig Layout -> [(KeyMask, KeySym)]) -> (XConfig Layout -> [((KeyMask, KeySym), X ())]) -> Reader (XConfig Layout) (M.Map (KeyMask, KeySym) (X ())) -customize ds is = Reader (keys defaultConfig) >>= delete ds >>= insert is +customize conf ds is = Reader (keys conf) >>= delete ds >>= insert is delete :: (MonadReader r m, Ord a) => (r -> [a]) -> M.Map a b -> m (M.Map a b) delete dels kmap = asks dels >>= return . foldr M.delete kmap |