From 80a716edf95ca61b347d8f20b080f88f4bf55bbf Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 7 Aug 2020 01:49:40 +0100 Subject: String index as progress bar --- src/Xmobar/Plugins/Monitors/Common/Output.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Xmobar/Plugins/Monitors/Common/Output.hs b/src/Xmobar/Plugins/Monitors/Common/Output.hs index c41ef19..4733a9f 100644 --- a/src/Xmobar/Plugins/Monitors/Common/Output.hs +++ b/src/Xmobar/Plugins/Monitors/Common/Output.hs @@ -221,9 +221,12 @@ showPercentBar v x = do bb <- getConfigValue barBack bf <- getConfigValue barFore bw <- getConfigValue barWidth - let len = min bw $ round (fromIntegral bw * x) - s <- colorizeString v (take len $ cycle bf) - return $ s ++ take (bw - len) (cycle bb) + let c = bw < 1 + w = if c then length bf else bw + len = min w $ round (fromIntegral w * x) + bfs = if c then [bf !! (len - 1)] else take len $ cycle bf + s <- colorizeString v bfs + return $ s ++ if c then "" else take (bw - len) (cycle bb) showIconPattern :: Maybe IconPattern -> Float -> Monitor String showIconPattern Nothing _ = return "" -- cgit v1.2.3