From 7241e54385700f4c52a0861b71aa84ab2d19bdf8 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 16 Sep 2015 02:38:24 +0200 Subject: Colorize active/inactive topics with different colors --- xmonad.hs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/xmonad.hs b/xmonad.hs index f0cebc0..892b9d9 100644 --- a/xmonad.hs +++ b/xmonad.hs @@ -60,7 +60,7 @@ import XMonad.Util.Replace (replace) import Control.Monad (when) import System.Environment (getArgs) -import Data.Maybe (fromMaybe, fromJust, isNothing, isJust) +import Data.Maybe (fromMaybe, fromJust, isNothing, isJust, mapMaybe) import Data.Ord (comparing) -- for hostname handling (no windows key on "Australien") @@ -170,14 +170,19 @@ topicsConfig = TopicConfig topicsGrid = withWindowSet $ \w -> do - let wss = W.workspaces w - usednames = filter (\w -> w /= "NSP") $ map W.tag $ wss - newnames = filter (\used -> (show used `notElem` (map show topics))) usednames - gridselect topicsGridConfig (map (\t -> (t, t)) (topics ++ newnames)) + let wss = filter (\w -> W.tag w /= "NSP") $ W.workspaces w + topicMap = map (\t -> (W.tag t, t)) wss + newTopics = filter (\used -> ((W.tag used) `notElem` topics)) wss + sortedTopics = mapMaybe (\name -> lookup name topicMap) topics + gridselect topicsGridConfig $ map (\t -> (W.tag t, t)) $ sortedTopics ++ newTopics -promptedGoto = topicsGrid >>= flip whenJust (switchTopic topicsConfig) +promptedGoto = do + topic <- topicsGrid + whenJust topic (switchTopic topicsConfig . W.tag) -promptedShift = topicsGrid >>= \x -> whenJust x $ \y -> windows (W.greedyView y . W.shift y) +promptedShift = do + topic <- topicsGrid + whenJust topic $ (\y -> windows (W.greedyView y . W.shift y)) . W.tag --}}} @@ -277,15 +282,21 @@ historyGridConfig = defaultGSConfig , gs_font = font } +topicsColorizer :: W.Workspace tag layout stack -> Bool -> X (String, String) +topicsColorizer topic selected + | empty && selected = return ("#f4f6f6", "#002b36") + | selected = return ("#839596", "#002b36") + | empty = return ("#001014", "#839496") + | otherwise = return ("#002b36", "#ffffff") + where + empty = null $ W.integrate' $ W.stack topic + +topicsGridConfig :: GSConfig (W.Workspace tag layout stack) topicsGridConfig = defaultGSConfig { gs_navigate = navNSearch , gs_font = font - , gs_colorizer = colorizer + , gs_colorizer = topicsColorizer } - where - colorizer topic selected - | selected = return ("#839596", "#002b36") - | otherwise = return ("#002b36", "#839496") confirmConfig :: GSConfig Bool confirmConfig = defaultGSConfig -- cgit v1.2.3