about summary refs log tree commit diff
path: root/src/XMonad/Actions/PerConditionKeys.hs
diff options
context:
space:
mode:
authorazahi <azahi@teknik.io>2018-06-12 00:21:36 +0300
committerazahi <azahi@teknik.io>2018-06-12 00:21:36 +0300
commit80c494ea343b0518630536472266a9b200b0fe16 (patch)
tree247b65e31443e8fbe85639d7cede630c7e98ed4d /src/XMonad/Actions/PerConditionKeys.hs
Initial commit
Diffstat (limited to '')
-rw-r--r--src/XMonad/Actions/PerConditionKeys.hs23
1 files changed, 23 insertions, 0 deletions
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 ()

Consider giving Nix/NixOS a try! <3