mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-28 02:31:51 -07:00
Merge pull request #794 from slotThe/ezconfig/remapkeysp
X.U.EZConfig: Add remapKeysP
This commit is contained in:
@@ -100,6 +100,11 @@
|
|||||||
|
|
||||||
### Bug Fixes and Minor Changes
|
### Bug Fixes and Minor Changes
|
||||||
|
|
||||||
|
* `XMonad.Util.EZConfig`
|
||||||
|
|
||||||
|
- Added `remapKeysP`, which remaps keybindings from one binding to
|
||||||
|
another.
|
||||||
|
|
||||||
* `XMonad.Util.NamedScratchpad`
|
* `XMonad.Util.NamedScratchpad`
|
||||||
|
|
||||||
- Added `addExclusives`, `resetFocusedNSP`, `setNoexclusive`,
|
- Added `addExclusives`, `resetFocusedNSP`, `setNoexclusive`,
|
||||||
|
@@ -24,6 +24,7 @@ module XMonad.Util.EZConfig (
|
|||||||
-- * Adding or removing keybindings
|
-- * Adding or removing keybindings
|
||||||
|
|
||||||
additionalKeys, additionalKeysP,
|
additionalKeys, additionalKeysP,
|
||||||
|
remapKeysP,
|
||||||
removeKeys, removeKeysP,
|
removeKeys, removeKeysP,
|
||||||
additionalMouseBindings, removeMouseBindings,
|
additionalMouseBindings, removeMouseBindings,
|
||||||
|
|
||||||
@@ -106,6 +107,40 @@ additionalKeysP :: XConfig l -> [(String, X ())] -> XConfig l
|
|||||||
additionalKeysP conf keyList =
|
additionalKeysP conf keyList =
|
||||||
conf { keys = \cnf -> M.union (mkKeymap cnf keyList) (keys conf cnf) }
|
conf { keys = \cnf -> M.union (mkKeymap cnf keyList) (keys conf cnf) }
|
||||||
|
|
||||||
|
-- |
|
||||||
|
-- Remap keybindings from one binding to another. More precisely, the
|
||||||
|
-- input list contains pairs of the form @(TO, FROM)@, and maps the
|
||||||
|
-- action bound to @FROM@ to the key @TO@. For example, the following
|
||||||
|
-- would bind @"M-m"@ to what's bound to @"M-c"@ (which is to close the
|
||||||
|
-- focused window, in this case):
|
||||||
|
--
|
||||||
|
-- > main :: IO ()
|
||||||
|
-- > main = xmonad $ def `remapKeysP` [("M-m", "M-c")]
|
||||||
|
--
|
||||||
|
-- NOTE: Submaps are not transparent, and thus these keys can't be
|
||||||
|
-- accessed in this way: more explicitly, the @FROM@ string may **not**
|
||||||
|
-- be a submap. However, the @TO@ can be a submap without problems.
|
||||||
|
-- This means that
|
||||||
|
--
|
||||||
|
-- > xmonad $ def `remapKeysP` [("M-m", "M-c a")]
|
||||||
|
--
|
||||||
|
-- is illegal (and indeed will just disregard the binding altogether),
|
||||||
|
-- while
|
||||||
|
--
|
||||||
|
-- > xmonad $ def `remapKeysP` [("M-c a", "M-m")]
|
||||||
|
--
|
||||||
|
-- is totally fine.
|
||||||
|
remapKeysP :: XConfig l -> [(String, String)] -> XConfig l
|
||||||
|
remapKeysP conf keyList =
|
||||||
|
conf { keys = \cnf -> mkKeymap cnf (keyList' cnf) <> keys conf cnf }
|
||||||
|
where
|
||||||
|
keyList' :: XConfig Layout -> [(String, X ())]
|
||||||
|
keyList' cnf =
|
||||||
|
mapMaybe (traverse (\s -> case readKeySequence cnf s of
|
||||||
|
Just [ks] -> keys conf cnf M.!? ks
|
||||||
|
_ -> Nothing))
|
||||||
|
keyList
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
-- Remove standard keybindings you're not using. Example use:
|
-- Remove standard keybindings you're not using. Example use:
|
||||||
--
|
--
|
||||||
|
Reference in New Issue
Block a user