From 0306ec4294f6d825ca65c7b0c98a80a3bced8fdf Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 22:31:10 +0200 Subject: tv: lol display-manager --- tv/2configs/xserver/xmonad/Util/Submap.hs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tv/2configs/xserver/xmonad/Util/Submap.hs (limited to 'tv/2configs/xserver/xmonad/Util/Submap.hs') diff --git a/tv/2configs/xserver/xmonad/Util/Submap.hs b/tv/2configs/xserver/xmonad/Util/Submap.hs new file mode 100644 index 000000000..b09b97cc2 --- /dev/null +++ b/tv/2configs/xserver/xmonad/Util/Submap.hs @@ -0,0 +1,31 @@ +-- This module is based on Jason Creighton's XMonad.Actions.Submap + +module Util.Submap + ( submapString + ) where + +import Data.Bits +import XMonad hiding (keys) +import qualified Data.Map as M +import Control.Monad.Fix (fix) + + +-- | Like 'XMonad.Actions.Submap.submapDefault', but provides the looked up string to the default action. +submapString :: (String -> X ()) -> M.Map (KeyMask, KeySym) (X ()) -> X () +submapString def keys = do + XConf { theRoot = root, display = d } <- ask + + (m, s, str) <- io $ allocaXEvent $ \p -> fix $ \nextkey -> do + maskEvent d keyPressMask p + KeyEvent { ev_keycode = code, ev_state = m } <- getEvent p + keysym <- keycodeToKeysym d code 0 + if isModifierKey keysym + then nextkey + else do + (mbKeysym, str) <- lookupString (asKeyEvent p) + return (m, keysym, str) + + -- Remove num lock mask and Xkb group state bits + m' <- cleanMask $ m .&. ((1 `shiftL` 12) - 1) + + maybe (def str) id (M.lookup (m', s) keys) -- cgit v1.2.3