aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Common.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-12-09 00:40:01 -0700
committerJosh Rahm <joshuarahm@gmail.com>2023-12-09 00:43:01 -0700
commit7fcb150943032880abd5a0be6421a68b9cf234a5 (patch)
treee962d37efd6f67c1c9af194ccdbae48b967eff9a /src/Rahm/Desktop/Common.hs
parent04a1fd2e2f2eaa9878c4bc67351784d6685ca22b (diff)
downloadrde-7fcb150943032880abd5a0be6421a68b9cf234a5.tar.gz
rde-7fcb150943032880abd5a0be6421a68b9cf234a5.tar.bz2
rde-7fcb150943032880abd5a0be6421a68b9cf234a5.zip
Added BorderColors.hs
This module manager border colors for the windows and handles automatically maintaining the colors across stack changes. This also adds green borders to pinned windows to differentiate them from normal windows.
Diffstat (limited to 'src/Rahm/Desktop/Common.hs')
-rw-r--r--src/Rahm/Desktop/Common.hs52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/Rahm/Desktop/Common.hs b/src/Rahm/Desktop/Common.hs
index 307dd89..c10dd64 100644
--- a/src/Rahm/Desktop/Common.hs
+++ b/src/Rahm/Desktop/Common.hs
@@ -7,9 +7,6 @@ module Rahm.Desktop.Common
getString,
askWindowId,
windowJump,
- withBorderColor,
- withBorderColorE,
- withBorderColorM,
withBorderWidth,
getCurrentScreen,
gotoWorkspace,
@@ -17,7 +14,6 @@ module Rahm.Desktop.Common
getCurrentWorkspace,
getCurrentLocation,
runMaybeT_,
- setBorderColor,
click,
pointerLocation,
pointerWindow,
@@ -140,54 +136,6 @@ askWindowId = do
windowJump :: X ()
windowJump = mapM_ (focus . head) =<< askWindowId
--- Have to add a definition because Stack uses an ancient version of
--- transformers for some reason.
-myFinallyE :: (Monad m) => ExceptT e m a -> ExceptT e m () -> ExceptT e m a
-myFinallyE m closer = catchE (m <* closer) (\e -> closer >> throwE e)
-
--- Temporarily set the border color of the given windows.
-withBorderColorE :: String -> [Window] -> ExceptT e X a -> ExceptT e X a
-withBorderColorE color wins fn = do
- cleanup <- lift (setBorderColor color wins)
- myFinallyE fn (lift cleanup)
-
--- Set the border color for the given windows. This function returns another
--- function that should be used to clean up the border changes.
-setBorderColor :: String -> [Window] -> X (X ())
-setBorderColor color wins = do
- d <- asks display
- (px, oPx, fPx) <-
- (,,)
- <$> stringToPixel d color
- <*> (stringToPixel d =<< asks (normalBorderColor . config))
- <*> (stringToPixel d =<< asks (focusedBorderColor . config))
-
- (colorName, oColorName, fColorName) <-
- (,,)
- <$> io (pixelToString d px)
- <*> io (pixelToString d oPx)
- <*> io (pixelToString d fPx)
-
- forM_ wins $ \w ->
- setWindowBorderWithFallback d w colorName px
-
- return $ do
- forM_ wins $ \w ->
- setWindowBorderWithFallback d w oColorName oPx
- withFocused $ \fw ->
- when (fw `elem` wins) $
- setWindowBorderWithFallback d fw fColorName fPx
-
-withBorderColorM :: String -> [Window] -> MaybeT X a -> MaybeT X a
-withBorderColorM s ws fn = toMaybeT $ withBorderColorE s ws (toExceptT fn)
- where
- toExceptT (MaybeT fn) = ExceptT $ maybe (Left ()) Right <$> fn
- toMaybeT (ExceptT fn) = MaybeT $ either (const Nothing) Just <$> fn
-
-withBorderColor :: String -> [Window] -> X a -> X a
-withBorderColor s ws fn =
- either absurd id <$> runExceptT (withBorderColorE s ws (lift fn))
-
withBorderWidth :: Int -> [Window] -> X a -> X a
withBorderWidth width ws fn = do
d <- asks display