aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Common.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-04-18 01:31:22 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:46 -0600
commit6d633961451e1ab4747dcf1b5d3a6ea672d4d938 (patch)
tree3ebc893496656d477a07dd02b5e6b36b69c29f8b /src/Rahm/Desktop/Common.hs
parent3a26f3eb4f02052fdb97dcdd884f408d52b383a9 (diff)
downloadrde-6d633961451e1ab4747dcf1b5d3a6ea672d4d938.tar.gz
rde-6d633961451e1ab4747dcf1b5d3a6ea672d4d938.tar.bz2
rde-6d633961451e1ab4747dcf1b5d3a6ea672d4d938.zip
Add basic language for moving windows around
Diffstat (limited to 'src/Rahm/Desktop/Common.hs')
-rw-r--r--src/Rahm/Desktop/Common.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Rahm/Desktop/Common.hs b/src/Rahm/Desktop/Common.hs
index 926d5ff..5a5aecf 100644
--- a/src/Rahm/Desktop/Common.hs
+++ b/src/Rahm/Desktop/Common.hs
@@ -2,6 +2,7 @@ module Rahm.Desktop.Common where
import Prelude hiding ((!!))
+import Control.Monad (void)
import Control.Monad.Trans.Maybe
import XMonad.Actions.DynamicWorkspaces
import XMonad.Util.Run
@@ -42,6 +43,14 @@ masterWindow = MaybeT $ withWindowSet $ \ss ->
(a:_) -> return $ Just a
_ -> return Nothing
+windowsInWorkspace :: WorkspaceId -> X [Location]
+windowsInWorkspace wid =
+ withWindowSet $
+ return . concatMap (\ws ->
+ if S.tag ws == wid
+ then map (Location wid . Just) $ S.integrate' (S.stack ws)
+ else []) . S.workspaces
+
data WinPrompt = WinPrompt
instance XPrompt WinPrompt where
@@ -84,3 +93,11 @@ getCurrentWorkspace = withWindowSet $
\(S.StackSet (S.Screen (S.Workspace t _ _) _ _) _ _ _) -> do
return t
+getCurrentLocation :: X Location
+getCurrentLocation = do
+ ws <- getCurrentWorkspace
+ win <- withWindowSet (return . peek)
+ return (Location ws win)
+
+runMaybeT_ :: (Monad m) => MaybeT m a -> m ()
+runMaybeT_ = void . runMaybeT