summaryrefslogtreecommitdiffstats
path: root/pkgs/haskell/xmonad-tv/src/XMonad
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-04 01:55:06 +0000
committertv <tv@krebsco.de>2026-12-04 03:05:12 +0000
commit607fb1010baae845910e75ba31687bffb259636b (patch)
tree13feecaa2c3c2091c83ea80ebfa1cdbe4db8f361 /pkgs/haskell/xmonad-tv/src/XMonad
parent3b8389042fde0a9dcb1eaa8d6401e8332915af88 (diff)
xmonad-tv: update from the dirt
Diffstat (limited to 'pkgs/haskell/xmonad-tv/src/XMonad')
-rw-r--r--pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs37
-rw-r--r--pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs14
2 files changed, 51 insertions, 0 deletions
diff --git a/pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs b/pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs
index 74222712..2a234fe2 100644
--- a/pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs
+++ b/pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs
@@ -1,9 +1,17 @@
+{-# LANGUAGE LambdaCase #-}
module XMonad.Extra where
import XMonad
+import System.IO (hPutStrLn, stderr)
import qualified Data.Map as Map
+import qualified Data.Maybe
import qualified XMonad.StackSet as W
+headMaybe :: [a] -> Maybe a
+headMaybe = \case
+ x : _ -> Just x
+ [] -> Nothing
+
isFloating :: Window -> WindowSet -> Bool
isFloating w =
@@ -12,3 +20,32 @@ isFloating w =
isFloatingX :: Window -> X Bool
isFloatingX w =
isFloating w <$> gets windowset
+
+withFocusedMaybe :: (Maybe Window -> X a) -> X a
+withFocusedMaybe f =
+ withWindowSet $ f . W.peek
+
+-- Return list of all focused windows.
+-- The first element is the focused window on the focused workspace.
+-- If there is any error, the empty list will be returned instead.
+withAllFocused :: X [Window]
+withAllFocused = do
+ ws <- gets $
+ map W.focus . Data.Maybe.catMaybes
+ . map W.stack
+ . W.workspaces
+ . windowset
+ withFocusedMaybe $ \case
+ Just w ->
+ if headMaybe ws == Just w then
+ return ws
+ else do
+ io $ hPutStrLn stderr $ "withAllFocused: error: bad focus: " <> show (w, ws)
+ return []
+
+ Nothing -> do
+ io $ hPutStrLn stderr $ "withAllFocused: error: no focus"
+ return []
+
+
+
diff --git a/pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs b/pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs
index 7a8947f3..8fc2a62a 100644
--- a/pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs
+++ b/pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs
@@ -111,6 +111,19 @@ ewmhDesktopsExtraEventHook = \case
createNames = Set.toAscList $
Set.difference createNameSet renamesTo
+ when ( not (null createNames)
+ || not (null deleteNames)
+ || not (null renames)
+ ) $ do
+ let optional c v = if c then v else mempty
+ let unlessNull c = optional (not (null c))
+ trace $ unlines $ filter (/= mempty)
+ [ "_NET_DESKTOP_NAMES:"
+ , unlessNull createNames $ " create: " <> show createNames
+ , unlessNull deleteNames $ " delete: " <> show deleteNames
+ , unlessNull renames $ " rename: " <> show renames
+ ]
+
mapM_ addHiddenWorkspace createNames
mapM_ removeEmptyWorkspaceByTag deleteNames
when (not (null renames)) $ do
@@ -123,6 +136,7 @@ ewmhDesktopsExtraEventHook = \case
modifyWindowSet $ mapWorkspace rename
+ -- if using removeWorkspaceByTag, then names = sort newNames
names <- gets $ map tag . sort . workspaces . windowset
when (names /= newNames) $ do