From 80c494ea343b0518630536472266a9b200b0fe16 Mon Sep 17 00:00:00 2001 From: azahi Date: Tue, 12 Jun 2018 00:21:36 +0300 Subject: Initial commit --- src/XMonad/Actions/PerConditionKeys.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/XMonad/Actions/PerConditionKeys.hs (limited to 'src/XMonad/Actions/PerConditionKeys.hs') diff --git a/src/XMonad/Actions/PerConditionKeys.hs b/src/XMonad/Actions/PerConditionKeys.hs new file mode 100644 index 0000000..85469d6 --- /dev/null +++ b/src/XMonad/Actions/PerConditionKeys.hs @@ -0,0 +1,23 @@ +module XMonad.Actions.PerConditionKeys + ( XCond(..) + , chooseAction + , bindOn + ) where + +import Data.List +import XMonad +import qualified XMonad.StackSet as S + +data XCond = WS | LD + +chooseAction :: XCond -> (String -> X ()) -> X () +chooseAction WS f = withWindowSet (f . S.currentTag) +chooseAction LD f = withWindowSet (f . description . S.layout . S.workspace . S.current) + +bindOn :: XCond -> [(String, X ())] -> X () +bindOn xc bindings = chooseAction xc chooser + where chooser x = case find ((x ==) . fst) bindings of + Just (_, action) -> action + Nothing -> case find (("" ==) . fst) bindings of + Just (_, action) -> action + Nothing -> return () -- cgit 1.4.1