diff options
| author | Josh Rahm <rahm@google.com> | 2022-08-03 14:00:30 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:46 -0600 |
| commit | 4fd7572c12c9cdc2e034fd9cbaf1423d40153081 (patch) | |
| tree | e2f9b59a482e5441eadaec3dc6f4d3856e7cf5e7 /src/Rahm/Desktop/Keys/Wml.hs | |
| parent | 2ba96e5577f2f0b71a2aecffe4f6d8762de47442 (diff) | |
| download | rde-4fd7572c12c9cdc2e034fd9cbaf1423d40153081.tar.gz rde-4fd7572c12c9cdc2e034fd9cbaf1423d40153081.tar.bz2 rde-4fd7572c12c9cdc2e034fd9cbaf1423d40153081.zip | |
Add new conditional description for workspaces.
This adds the "<" condition, it used as "in"
i.e. "<l₀l₁w₀w₁" reads as "if l₀ is a subset of l₁, then w₀ else w₁"
Useful for macro programming like, if Spotify is on the current
workspace, then go back to where I came from, otherwise jump to Spotify.
This can be achieved with the following (assuming Spotify is marked with
"s"):
"<H-g><s@.'@s"
"if spotify (s) is in the set of the windows on the current screen (@.), jump
back to where I came from (workspace '), otherwise goto the workspace
spotify is on (@s)."
Diffstat (limited to 'src/Rahm/Desktop/Keys/Wml.hs')
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index adb1d9f..647234c 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -267,18 +267,15 @@ readNextWorkspace = (_, _, "@") -> do loc <- readNextLocationSet - MaybeT (return $ justWorkspace . locationWorkspace <$> head loc) + MaybeT $ fromX $ withWindowSet $ \ws -> return $ do + win <- locationWindow =<< head loc + winLocation <- W.findWindow ws win + (justWorkspace . W.tag) <$> W.getLocationWorkspace winLocation (_, _, "~") -> justWorkspace . accompaningWorkspace <$> readNextWorkspaceName (_, _, " ") -> mt $ justWorkspace . accompaningWorkspace <$> getCurrentWorkspace - (_, _, "~") -> do - ws <- readNextWorkspace - case workspaceName ws of - Just [a] | isAlphaNum a -> - return (justWorkspace $ accompaningWorkspace [a]) - _ -> MaybeT (return Nothing) (_, _, "_") -> return blackHoleWorkspace (_, _, "-") -> return alternateWorkspace @@ -294,6 +291,28 @@ readNextWorkspace = then ws3 else ws4 + (_, _, "<") -> do + lift . fromX $ + logs Trace "Doing thing" + + l1 <- map locationWindow <$> readNextLocationSet + + lift . fromX $ + logs Trace "%s" (show l1) + + l2 <- map locationWindow <$> readNextLocationSet + + ws1 <- readNextWorkspace + ws2 <- readNextWorkspace + + (lift . fromX) $ (logs Trace "%s < %s? %s" (show l1) (show l2) (show $ all (`elem`l2) l1) :: X ()) + (lift . fromX) $ (logs Trace "%s %s" (show $ workspaceName ws1) (show $ workspaceName ws2)) + + return $ + if all (`elem`l2) l1 + then ws1 + else ws2 + (mask, keysym, _) -> do macro <- (MaybeT . fromX) (Map.lookup (mask, keysym) . workspaceMacros <$> XS.get) fromMaybeTX $ workspaceForKeysT macro |