aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Marking.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-03 14:00:30 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:46 -0600
commit4fd7572c12c9cdc2e034fd9cbaf1423d40153081 (patch)
treee2f9b59a482e5441eadaec3dc6f4d3856e7cf5e7 /src/Rahm/Desktop/Marking.hs
parent2ba96e5577f2f0b71a2aecffe4f6d8762de47442 (diff)
downloadrde-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/Marking.hs')
-rw-r--r--src/Rahm/Desktop/Marking.hs26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/Rahm/Desktop/Marking.hs b/src/Rahm/Desktop/Marking.hs
index 4da2a46..f239399 100644
--- a/src/Rahm/Desktop/Marking.hs
+++ b/src/Rahm/Desktop/Marking.hs
@@ -9,7 +9,9 @@ module Rahm.Desktop.Marking (
markAllLocations,
farLeftWindow,
farRightWindow,
- windowLocation
+ windowLocation,
+ markWindow,
+ Mark
) where
import Prelude hiding (head)
@@ -27,6 +29,7 @@ import Data.List.Safe (head)
import Data.Map (Map)
import Data.Sequence (Seq(..))
import Rahm.Desktop.Common
+import Rahm.Desktop.Logger
import Rahm.Desktop.History
import Rahm.Desktop.Hooks.WindowChange
import Rahm.Desktop.Workspaces
@@ -83,21 +86,26 @@ withMaybeFocused :: (Maybe Window -> X a) -> X a
withMaybeFocused f = withWindowSet $ f . peek
markAllLocations :: Mark -> [Location] -> X ()
-markAllLocations mark locs =
+markAllLocations mark locs = do
+ logs Debug "Marking locations %s as \"%s\"" (show locs) (show mark)
+
XS.modify $ \m ->
m {
markStateMap = Map.insert mark locs (markStateMap m)
}
-markCurrentWindow :: Mark -> X ()
-markCurrentWindow mark = do
+markWindow :: Mark -> Window -> X ()
+markWindow mark window = do
+ logs Debug "Marking window %s as \"%s\"" (show window) (show mark)
+
ws <- getCurrentWorkspace
+ XS.modify $ \state@MarkState {markStateMap = ms} ->
+ state {
+ markStateMap = Map.insertWith (++) mark [Location ws $ Just window] ms
+ }
- withFocused $ \win ->
- XS.modify $ \state@MarkState {markStateMap = ms} ->
- state {
- markStateMap = Map.insertWith (++) mark [Location ws $ Just win] ms
- }
+markCurrentWindow :: Mark -> X ()
+markCurrentWindow = withFocused . markWindow
jumpToMark :: Mark -> X ()
jumpToMark mark = do