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/Main.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/Main.hs')
| -rw-r--r-- | src/Main.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs index 81a874b..a98e568 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,5 +1,6 @@ import XMonad +import XMonad.Hooks.DynamicProperty import Control.Monad.Trans.Class import Control.Monad.Reader import XMonad.Hooks.ManageDocks (docks) @@ -14,6 +15,7 @@ import qualified Data.Map as Map import Text.Printf import Rahm.Desktop.Swallow +import Rahm.Desktop.Marking import Rahm.Desktop.Common import Rahm.Desktop.XMobarLog import Rahm.Desktop.Keys @@ -51,6 +53,7 @@ main = do , startupHook = spawn fp , manageHook = composeAll [ isFullscreen --> doFullFloat + , doLogWindow , className =? "Tilda" --> doFloat , className =? "yakuake" --> doFloat , className =? "MPlayer" --> doFloat @@ -72,7 +75,10 @@ main = do composeAll [ fullscreenEventHook, remapHook, - swallowHook] + swallowHook, + dynamicTitle (composeAll [ + title =? "Spotify" --> doMarkWindow "s" + ])] , focusFollowsMouse = False , clickJustFocuses = False , logHook = xMobarLogHook xmobar @@ -83,6 +89,19 @@ changeHook :: Location -> Location -> X () changeHook l1 l2 = logs Info "Change %s -> %s" (show l1) (show l2) +doLogWindow :: ManageHook +doLogWindow = do + t <- title + c <- className + a <- appName + liftX $ logs Debug "New Window {title: \"%s\", class: \"%s\", appName: \"%s\"}" t c a + return (Endo id) + +doMarkWindow :: Mark -> ManageHook +doMarkWindow m = ask >>= (\w -> liftX (do + ws <- getCurrentWorkspace + markAllLocations m [Location ws (Just w)]) >> return (Endo id)) + doCenterFloat :: ManageHook doCenterFloat = ask >>= \w -> doF . W.float w . centerRect . snd =<< liftX (floatLocation w) |