aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorDevin Mullins <me@twifkak.com>2007-11-11 08:52:22 +0100
committerDevin Mullins <me@twifkak.com>2007-11-11 08:52:22 +0100
commit3352241c8cfe40428742ca6829ea427498f949e5 (patch)
tree70ac835b6176e0d174e7e4a12daf49f1d10b6f2e /XMonad
parent7b689c5b418d67d2376f6164b7f5fdac8a9717e4 (diff)
downloadXMonadContrib-3352241c8cfe40428742ca6829ea427498f949e5.tar.gz
XMonadContrib-3352241c8cfe40428742ca6829ea427498f949e5.tar.xz
XMonadContrib-3352241c8cfe40428742ca6829ea427498f949e5.zip
add helper module for writing configs
Looking for suggestions on this module. Does it belong here? Is there a better name? Should the additional* functions pass the modMask to their second argument? etc. darcs-hash:20071111075222-78224-05444e7180cbb34f2d4762774bb160bf90d9db22.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Util/EZConfig.hs55
1 files changed, 55 insertions, 0 deletions
diff --git a/XMonad/Util/EZConfig.hs b/XMonad/Util/EZConfig.hs
new file mode 100644
index 0000000..d2c0c5e
--- /dev/null
+++ b/XMonad/Util/EZConfig.hs
@@ -0,0 +1,55 @@
+--------------------------------------------------------------------
+-- |
+-- Module : XMonad.Util.EZConfig
+-- Copyright : Devin Mullins <me@twifkak.com>
+-- License : BSD3-style (see LICENSE)
+--
+-- Maintainer : Devin Mullins <me@twifkak.com>
+--
+-- Useful helper functions for amending the defaultConfig.
+--
+--------------------------------------------------------------------
+
+module XMonad.Util.EZConfig (
+ additionalKeys, removeKeys,
+ additionalMouseBindings, removeMouseBindings
+ ) where
+-- TODO: write tests
+
+import XMonad
+
+import qualified Data.Map as M
+import Graphics.X11.Xlib
+
+-- Add or override keybindings from the existing set. Example use:
+-- > main = xmonad $ defaultConfig { terminal = "urxvt" }
+-- > `additionalKeys`
+-- > [ ((mod1Mask, xK_m ), spawn "echo 'Hi, mom!' | dzen2 -p 4")
+-- > , ((mod1Mask, xK_BackSpace), withFocused hide) -- N.B. this is an absurd thing to do
+-- > ]
+-- This overrides the previous definition of mod-m.
+--
+-- Note that, unlike in xmonad 0.4 and previous, you can't use modMask to refer
+-- to the modMask you configured earlier. You must specify mod1Mask (or
+-- whichever), or add your own @myModMask = mod1Mask@ line.
+additionalKeys :: XConfig -> [((ButtonMask, KeySym), X ())] -> XConfig
+additionalKeys conf keysList =
+ conf { keys = \cnf -> M.union (M.fromList keysList) (keys conf cnf) }
+
+-- Remove standard keybidings you're not using. Example use:
+-- > main = xmonad $ defaultConfig { terminal = "urxvt" }
+-- > `removeKeys` [(mod1Mask .|. shiftMask, n) | n <- [xK_1 .. xK_9]]
+removeKeys :: XConfig -> [(ButtonMask, KeySym)] -> XConfig
+removeKeys conf keyList =
+ conf { keys = \cnf -> keys conf cnf `M.difference` M.fromList (zip keyList $ return ()) }
+
+-- Like additionalKeys, but for mouseBindings.
+additionalMouseBindings :: XConfig -> [((ButtonMask, Button), Window -> X ())] -> XConfig
+additionalMouseBindings conf mouseBindingsList =
+ conf { mouseBindings = \cnf -> M.union (M.fromList mouseBindingsList) (mouseBindings conf cnf) }
+
+-- Like removeKeys, but for mouseBindings.
+removeMouseBindings :: XConfig -> [(ButtonMask, Button)] -> XConfig
+removeMouseBindings conf mouseBindingList =
+ conf { mouseBindings = \cnf -> mouseBindings conf cnf `M.difference`
+ M.fromList (zip mouseBindingList $ return ()) }