summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2024-08-25 17:58:27 +0100
committerjao <jao@gnu.org>2024-08-25 17:58:27 +0100
commit3500eb6c7ba57fd2ce32f89fdde6edd6918679f9 (patch)
treebd72c18dde241977c56e6f836baba9cf35b9c568 /src/Xmobar/Plugins/Monitors
parent0c4daf1bcb9373479ac99767ee0dcb649e248f25 (diff)
downloadxmobar-3500eb6c7ba57fd2ce32f89fdde6edd6918679f9.tar.gz
xmobar-3500eb6c7ba57fd2ce32f89fdde6edd6918679f9.tar.bz2
wee refactoring
Diffstat (limited to 'src/Xmobar/Plugins/Monitors')
-rw-r--r--src/Xmobar/Plugins/Monitors/Weather.hs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Weather.hs b/src/Xmobar/Plugins/Monitors/Weather.hs
index a46bb4f..550779b 100644
--- a/src/Xmobar/Plugins/Monitors/Weather.hs
+++ b/src/Xmobar/Plugins/Monitors/Weather.hs
@@ -222,25 +222,23 @@ getData station = CE.catch
errHandler :: CE.SomeException -> IO String
errHandler _ = return "<Could not retrieve data>"
-formatSk :: Eq p => [(p, p)] -> p -> p -> p
-formatSk ((a,b):sks) sk d = if a == sk then b else formatSk sks sk d
-formatSk [] _ d = d
-
formatWeather
:: WeatherOpts -- ^ Formatting options from the cfg file
-> [(String,String)] -- ^ 'SkyConditionS' for 'WeatherX'
-> [WeatherInfo] -- ^ The actual weather info
-> Monitor String
-formatWeather opts sks
- [WI st ss y m d h (WindInfo wc wa wm wk wkh wms) v sk we tC tF dC dF r p] =
- do cel <- showWithColors show tC
+formatWeather opts sks [WI st ss y m d h wind v sk we tC tF dC dF r p] =
+ do let WindInfo wc wa wm wk wkh wms = wind
+ cel <- showWithColors show tC
far <- showWithColors show tF
- let sk' = formatSk sks (map toLower sk) ""
+ let sk' = findSk sks (map toLower sk) ""
we' = showWeather (weatherString opts) we
- we'' = formatSk sks (map toLower we') sk'
+ we'' = findSk sks (map toLower we') sk'
parseTemplate [st, ss, y, m, d, h, wc, wa, wm, wk, wkh
, wms, v, sk, sk', we', we'', cel, far
, show dC, show dF, show r , show p ]
+ where findSk ((a,b):xs) x df = if a == x then b else findSk xs x df
+ findSk [] _ df = df
formatWeather _ _ _ = getConfigValue naString
-- | Show the 'weather' field with a default string in case it was empty.