From 289271f1fbbfe8dad4fac812196ba26b281d1876 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 16 May 2022 02:53:01 +0100 Subject: Fix for -W "0" spec in logarithmic bars Should address issue #630. --- src/Xmobar/Plugins/Monitors/Common/Output.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Xmobar/Plugins/Monitors/Common/Output.hs b/src/Xmobar/Plugins/Monitors/Common/Output.hs index 248f276..d87263f 100644 --- a/src/Xmobar/Plugins/Monitors/Common/Output.hs +++ b/src/Xmobar/Plugins/Monitors/Common/Output.hs @@ -3,7 +3,7 @@ ------------------------------------------------------------------------------ -- | -- Module: Xmobar.Plugins.Monitors.Strings --- Copyright: (c) 2018, 2019, 2020 Jose Antonio Ortega Ruiz +-- Copyright: (c) 2018, 2019, 2020, 2022 Jose Antonio Ortega Ruiz -- License: BSD3-style (see LICENSE) -- -- Maintainer: jao@gnu.org @@ -261,9 +261,10 @@ logScaling f v = do l <- fromIntegral `fmap` getConfigValue low bw <- fromIntegral `fmap` getConfigValue barWidth let [ll, hh] = sort [l, h] + bw' = if bw > 0 then bw else 10 scaled x | x == 0.0 = 0 - | x <= ll = 1 / bw - | otherwise = f + logBase 2 (x / hh) / bw + | x <= ll = 1 / bw' + | otherwise = f + logBase 2 (x / hh) / bw' return $ scaled v showLogBar :: Float -> Float -> Monitor String -- cgit v1.2.3