From 7af1ddc5ebbe9d651ffbc057614be18637e69939 Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 30 Mar 2022 22:23:10 +0100 Subject: Fix: consistent use of configured nastring instead of hardcoded N/A --- src/Xmobar/Plugins/Monitors/Load.hs | 6 ++---- src/Xmobar/Plugins/Monitors/MPD.hs | 3 ++- src/Xmobar/Plugins/Monitors/Swap.hs | 7 +++---- src/Xmobar/Plugins/Monitors/Thermal.hs | 2 +- src/Xmobar/Plugins/Monitors/Top.hs | 5 +++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Xmobar/Plugins/Monitors/Load.hs b/src/Xmobar/Plugins/Monitors/Load.hs index 616b673..bc0af09 100644 --- a/src/Xmobar/Plugins/Monitors/Load.hs +++ b/src/Xmobar/Plugins/Monitors/Load.hs @@ -22,9 +22,7 @@ import System.Posix.Files (fileExist) -- | Default configuration. loadConfig :: IO MConfig -loadConfig = mkMConfig - "Load: " -- template - ["load1", "load5", "load15"] -- available replacements +loadConfig = mkMConfig "Load: " ["load1", "load5", "load15"] -- | Parses the contents of a loadavg proc file, returning -- the list of load averages @@ -43,4 +41,4 @@ runLoad _ = do d <- getConfigValue decDigits parseTemplate =<< mapM (showWithColors (showDigits d)) l) else - return "Load: N/A" + getConfigValue naString diff --git a/src/Xmobar/Plugins/Monitors/MPD.hs b/src/Xmobar/Plugins/Monitors/MPD.hs index c8c2dc9..7ecbc0c 100644 --- a/src/Xmobar/Plugins/Monitors/MPD.hs +++ b/src/Xmobar/Plugins/Monitors/MPD.hs @@ -95,7 +95,8 @@ mpdReady args = do parseMPD :: M.Response M.Status -> M.Response (Maybe M.Song) -> MOpts -> Monitor [String] -parseMPD (Left _) _ _ = return $ "N/A": repeat "" +parseMPD (Left _) _ _ = + getConfigValue naString >>= \na -> return $ na : repeat "" parseMPD (Right st) song opts = do songData <- parseSong song bar <- showPercentBar (100 * b) b diff --git a/src/Xmobar/Plugins/Monitors/Swap.hs b/src/Xmobar/Plugins/Monitors/Swap.hs index e8b2f54..f10afad 100644 --- a/src/Xmobar/Plugins/Monitors/Swap.hs +++ b/src/Xmobar/Plugins/Monitors/Swap.hs @@ -24,9 +24,8 @@ import qualified Xmobar.Plugins.Monitors.Swap.Linux as MS #endif swapConfig :: IO MConfig -swapConfig = mkMConfig - "Swap: %" -- template - ["usedratio", "total", "used", "free"] -- available replacements +swapConfig = mkMConfig "Swap: %" + ["usedratio", "total", "used", "free"] formatSwap :: [Float] -> Monitor [String] formatSwap (r:xs) = do @@ -34,7 +33,7 @@ formatSwap (r:xs) = do other <- mapM (showWithColors (showDigits d)) xs ratio <- showPercentWithColors r return $ ratio:other -formatSwap _ = return $ replicate 4 "N/A" +formatSwap _ = replicate 4 `fmap` getConfigValue naString runSwap :: [String] -> Monitor String runSwap _ = diff --git a/src/Xmobar/Plugins/Monitors/Thermal.hs b/src/Xmobar/Plugins/Monitors/Thermal.hs index 320ae17..bfbbda0 100644 --- a/src/Xmobar/Plugins/Monitors/Thermal.hs +++ b/src/Xmobar/Plugins/Monitors/Thermal.hs @@ -36,4 +36,4 @@ runThermal args = do then do number <- io $ fmap ((read :: String -> Int) . stringParser (1, 0)) (B.readFile file) thermal <- showWithColors show number parseTemplate [ thermal ] - else return $ "Thermal (" ++ zone ++ "): N/A" + else getConfigValue naString diff --git a/src/Xmobar/Plugins/Monitors/Top.hs b/src/Xmobar/Plugins/Monitors/Top.hs index e99ec3b..3bfe6fd 100644 --- a/src/Xmobar/Plugins/Monitors/Top.hs +++ b/src/Xmobar/Plugins/Monitors/Top.hs @@ -3,7 +3,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Top --- Copyright : (c) 2010, 2011, 2012, 2013, 2014, 2018 Jose A Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2012, 2013, 2014, 2018, 2022 Jose A Ortega Ruiz -- License : BSD-style (see LICENSE) -- -- Maintainer : Jose A Ortega Ruiz @@ -127,7 +127,8 @@ runTop tref scale _ = do (no, ps, ms) <- io $ topProcesses tref scale pstr <- showTimeInfos ps mstr <- showMemInfos ms - parseTemplate $ show no : concat (zipWith (++) pstr mstr) ++ repeat "N/A" + na <- getConfigValue naString + parseTemplate $ show no : concat (zipWith (++) pstr mstr) ++ repeat na startTop :: [String] -> Int -> (String -> IO ()) -> IO () startTop a r cb = do -- cgit v1.2.3