summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2015-09-16 02:38:24 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2015-09-16 02:38:24 +0200
commit7241e54385700f4c52a0861b71aa84ab2d19bdf8 (patch)
tree2e552e8d78577d9fe688105cea9bd53c7f9e3acd
parent62266ec33b38614a35967dec5b49ee10893ef9c6 (diff)
downloadxmonad-config-7241e54385700f4c52a0861b71aa84ab2d19bdf8.tar.gz
xmonad-config-7241e54385700f4c52a0861b71aa84ab2d19bdf8.tar.xz
xmonad-config-7241e54385700f4c52a0861b71aa84ab2d19bdf8.zip
Colorize active/inactive topics with different colors
-rw-r--r--xmonad.hs35
1 files 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