diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2015-09-16 02:38:24 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-09-16 02:38:24 +0200 |
commit | 7241e54385700f4c52a0861b71aa84ab2d19bdf8 (patch) | |
tree | 2e552e8d78577d9fe688105cea9bd53c7f9e3acd | |
parent | 62266ec33b38614a35967dec5b49ee10893ef9c6 (diff) | |
download | xmonad-config-7241e54385700f4c52a0861b71aa84ab2d19bdf8.tar.gz xmonad-config-7241e54385700f4c52a0861b71aa84ab2d19bdf8.tar.xz xmonad-config-7241e54385700f4c52a0861b71aa84ab2d19bdf8.zip |
Colorize active/inactive topics with different colors
-rw-r--r-- | xmonad.hs | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -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 |