diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2015-09-16 02:39:14 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-09-16 02:40:03 +0200 |
commit | 29e007817368b0eaad8e60179747dcd99347a285 (patch) | |
tree | b0934777713712e5befc8c0f895cc1c6d8893604 | |
parent | 7241e54385700f4c52a0861b71aa84ab2d19bdf8 (diff) | |
download | xmonad-config-29e007817368b0eaad8e60179747dcd99347a285.tar.gz xmonad-config-29e007817368b0eaad8e60179747dcd99347a285.tar.xz xmonad-config-29e007817368b0eaad8e60179747dcd99347a285.zip |
Improve code style in topics output log hook
-rw-r--r-- | xmonad.hs | 45 |
1 files changed, 28 insertions, 17 deletions
@@ -317,28 +317,39 @@ confirm = Confirm.confirm confirmConfig myLogHook statusFile = do ewmhDesktopsLogHook - topicOutput <- lastTopics topicsConfig pp - otherOutput <- dynamicLogString pp { ppVisible = \_ -> "" - , ppCurrent = \_ -> "" - , ppUrgent = \_ -> "" - , ppHidden = \_ -> "" - } + topicOutput <- lastTopics + otherOutput <- dynamicLogString ppWithoutTopics io $ ppOutput pp (topicOutput ++ otherOutput) where - pp = myPP statusFile - lastTopics tg pp = do + pp = myPP statusFile + ppWithDepth ws = pp { ppHidden = addDepth ws ppHidden + , ppVisible = addDepth ws ppVisible + , ppUrgent = addDepth ws ppUrgent + } + ppWithoutTopics = pp { ppVisible = \_ -> "" + , ppCurrent = \_ -> "" + , ppUrgent = \_ -> "" + , ppHidden = \_ -> "" + } + + isEmpty = isNothing . W.stack + emptyTopics winset = map W.tag $ filter isEmpty $ W.workspaces winset + isVisible winset topic = topic /= "NSP" && (notElem topic $ emptyTopics winset) + + topicWithDepth topic = ((topic ++ ":") ++) . show + getDepth ws topic = fromJust $ elemIndex topic $ ws ++ [topic] + addDepth ws proj topic = proj pp $ topicWithDepth topic $ getDepth ws topic + sortTopics ws = take (maxTopicHistory topicsConfig) . + sortBy (comparing $ (getDepth ws) . W.tag) . + namedScratchpadFilterOutWorkspace + + lastTopics = do winset <- gets windowset urgents <- readUrgents - let empty_workspaces = map W.tag $ filter (isNothing . W.stack) $ W.workspaces winset - maxDepth = maxTopicHistory tg - setLastFocusedTopic (W.tag . W.workspace . W.current $ winset) - (\t -> (t `notElem` empty_workspaces && t /= "NSP")) + setLastFocusedTopic (W.tag . W.workspace . W.current $ winset) (isVisible winset) lastWs <- getLastFocusedTopics - let depth topic = fromJust $ elemIndex topic $ lastWs ++ [topic] - add_depth proj topic = proj pp . (((topic++":")++) . show) . depth $ topic - pp' = pp { ppHidden = add_depth ppHidden, ppVisible = add_depth ppVisible, ppUrgent = add_depth ppUrgent } - sortWindows = take maxDepth . sortBy (comparing $ depth . W.tag) . namedScratchpadFilterOutWorkspace - return $ pprWindowSet sortWindows urgents pp' winset + return $ pprWindowSet (sortTopics lastWs) urgents (ppWithDepth lastWs) winset + myEventHook = do ewmhDesktopsEventHook |