From 438f50cda56d2170931a6b45ce084c6deffeb86b Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 23 Nov 2022 12:30:41 -0700 Subject: Change WML to give precedence to macros over everything else. This makes it so one can record a macro to M- keys where the lookupString might be alphanumeric, but has another modifier. This allows one to write a macro for double tapping , for example. --- src/Rahm/Desktop/Keys/Wml.hs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/Rahm/Desktop/Keys') diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index a46bbac..4e63575 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -113,7 +113,7 @@ import Rahm.Desktop.XMobarLog.PendingBuffer ( addStringToPendingBuffer, setPendingBuffer, ) -import System.Exit (ExitCode (..), exitWith, exitSuccess) +import System.Exit (ExitCode (..), exitSuccess, exitWith) import Text.Printf (printf) import XMonad ( Default (def), @@ -336,7 +336,11 @@ readNextWorkspaceName = joinMaybe $ workspaceName <$> readNextWorkspace readNextWorkspace :: (KeyFeeder m) => MaybeT m Workspace readNextWorkspace = readNextKey $ \mask sym str -> do + macros <- (lift . fromX) $ workspaceMacros <$> XS.get + case (mask, sym, str) of + (mask, keysym, _) | (Just macro) <- Map.lookup (mask, keysym) macros -> do + fromMaybeTX $ workspaceForKeysT macro (_, e, _) | e == xK_Escape -> MaybeT $ return Nothing (_, _, [ch]) | isAlphaNum ch || ch == '*' -> return $ justWorkspace [ch] (_, _, "[") -> @@ -351,16 +355,23 @@ readNextWorkspace = ) (_, _, "(") -> justWorkspace - <$> (lift1 (adjacentWorkspace prev) =<< readNextWorkspaceName) + <$> ( lift1 (adjacentWorkspace prev) + =<< readNextWorkspaceName + ) (_, _, ")") -> justWorkspace - <$> (lift1 (adjacentWorkspace next) =<< readNextWorkspaceName) + <$> ( lift1 (adjacentWorkspace next) + =<< readNextWorkspaceName + ) (_, _, "^") -> mapMaybeT fromX $ MaybeT $ withWindowSet $ \ws -> return $ - (fmap (justWorkspace . W.tag . W.workspace . snd) . head) - (getHorizontallyOrderedScreens ws) + ( fmap + ( justWorkspace . W.tag . W.workspace . snd + ) + . head + ) (getHorizontallyOrderedScreens ws) (_, _, "'") -> fromMaybeTX $ justWorkspace . locationWorkspace <$> MaybeT lastLocation (_, _, ".") -> mt $ justWorkspace <$> getCurrentWorkspace (_, _, "$") -> MaybeT $ @@ -430,9 +441,6 @@ readNextWorkspace = if null l1 then ws2 else ws1 - (mask, keysym, _) -> do - macro <- (MaybeT . fromX) (Map.lookup (mask, keysym) . workspaceMacros <$> XS.get) - fromMaybeTX $ workspaceForKeysT macro where mt :: (KeyFeeder m) => X a -> MaybeT m a mt = lift . fromX -- cgit