aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-03 15:27:34 -0600
committerJosh Rahm <rahm@google.com>2022-08-03 15:27:34 -0600
commitc9159878868bea1fcc7d40d85f09cb29428ba0d5 (patch)
tree1622554944883266fada320dc3406333c97fc552
parentb67dbf6462187a9a8346a8d312b46b33e8d74fa3 (diff)
downloadrde-c9159878868bea1fcc7d40d85f09cb29428ba0d5.tar.gz
rde-c9159878868bea1fcc7d40d85f09cb29428ba0d5.tar.bz2
rde-c9159878868bea1fcc7d40d85f09cb29428ba0d5.zip
Actually, change the workspace conditional operator.
It was <l₀l₁w₀w₁ to condition on if l₀ is a subset of l₁, but this is redundant, instead add "?" that conditions of if l₀ is empty. So the new syntax is ?lw₀w₁ which is read, if the windowset l is not empty, then workspace w₀ else w₁. This is the same use-case as before. Handy for defining macros to, say, jump to Spotify if it's not on the current workspace, otherwise jump to the prior window. This is now accomplished with (assuming Spotify is marked 's'): <H-g>?&s@.'@s This reads as, if (?) the intersection between the Spotify window and the windows on the current workspace (&s@.) is not empty (if spotify is on the current window), go to the last workspace ('), otherwise go to the workspace Spotify is on (@s).
-rw-r--r--src/Rahm/Desktop/Keys/Wml.hs21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs
index 647234c..9074b66 100644
--- a/src/Rahm/Desktop/Keys/Wml.hs
+++ b/src/Rahm/Desktop/Keys/Wml.hs
@@ -291,27 +291,18 @@ readNextWorkspace =
then ws3
else ws4
- (_, _, "<") -> do
- lift . fromX $
- logs Trace "Doing thing"
+ -- ?&s@.'@s
- l1 <- map locationWindow <$> readNextLocationSet
-
- lift . fromX $
- logs Trace "%s" (show l1)
-
- l2 <- map locationWindow <$> readNextLocationSet
+ (_, _, "?") -> do
+ l1 <- 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
+ if null l1
+ then ws2
+ else ws1
(mask, keysym, _) -> do
macro <- (MaybeT . fromX) (Map.lookup (mask, keysym) . workspaceMacros <$> XS.get)