From 29e007817368b0eaad8e60179747dcd99347a285 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 16 Sep 2015 02:39:14 +0200 Subject: Improve code style in topics output log hook --- xmonad.hs | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/xmonad.hs b/xmonad.hs index 892b9d9..e4ec644 100644 --- a/xmonad.hs +++ b/xmonad.hs @@ -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 -- cgit v1.2.3