From 212b9c15ce5836c58716161191c3e3cf0df80093 Mon Sep 17 00:00:00 2001 From: slotThe Date: Mon, 23 Dec 2019 16:22:10 +0100 Subject: Add support for the "Weather" field --- changelog.md | 9 ++++++++- readme.md | 2 +- src/Xmobar/Plugins/Monitors/Weather.hs | 9 ++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index c19292f..22a9b8c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,11 @@ -## Version 0.32 +## Version 0.33 + +_New features_ + + - New template parameter `` for the `Weather` plugin, potentially + displaying specific weather conditions that are occurring near the station. + +## Version 0.32 (December, 2019) _New features_ diff --git a/readme.md b/readme.md index 6ace8fc..dd247e2 100644 --- a/readme.md +++ b/readme.md @@ -739,7 +739,7 @@ something like: - Variables that can be used with the `-t`/`--template` argument: `station`, `stationState`, `year`, `month`, `day`, `hour`, `windCardinal`, `windAzimuth`, `windMph`, `windKnots`, `windMs`, `windKmh` - `visibility`, `skyCondition`, `tempC`, `tempF`, + `visibility`, `skyCondition`, `weather`, `tempC`, `tempF`, `dewPointC`, `dewPointF`, `rh`, `pressure` - Default template: `: C, rh % ()` - Retrieves weather information from http://tgftp.nws.noaa.gov. diff --git a/src/Xmobar/Plugins/Monitors/Weather.hs b/src/Xmobar/Plugins/Monitors/Weather.hs index fb5732b..6ac1f4b 100644 --- a/src/Xmobar/Plugins/Monitors/Weather.hs +++ b/src/Xmobar/Plugins/Monitors/Weather.hs @@ -45,6 +45,7 @@ weatherConfig = mkMConfig , "visibility" , "skyCondition" , "skyConditionS" + , "weather" , "tempC" , "tempF" , "dewPointC" @@ -73,6 +74,7 @@ data WeatherInfo = , windInfo :: WindInfo , visibility :: String , skyCondition :: String + , weather :: String , tempC :: Int , tempF :: Int , dewPointC :: Int @@ -169,6 +171,7 @@ parseData = w <- pWind v <- getAfterString "Visibility: " sk <- getAfterString "Sky conditions: " + we <- getAfterString "Weather: " skipTillString "Temperature: " (tC,tF) <- pTemp skipTillString "Dew Point: " @@ -178,7 +181,7 @@ parseData = skipTillString "Pressure (altimeter): " p <- pPressure manyTill skipRestOfLine eof - return [WI st ss y m d h w v sk tC tF dC dF rh p] + return [WI st ss y m d h w v sk we tC tF dC dF rh p] defUrl :: String defUrl = "https://tgftp.nws.noaa.gov/data/observations/metar/decoded/" @@ -201,12 +204,12 @@ formatSk ((a,b):sks) sk = if a == sk then b else formatSk sks sk formatSk [] sk = sk formatWeather :: [(String,String)] -> [WeatherInfo] -> Monitor String -formatWeather sks [WI st ss y m d h (WindInfo wc wa wm wk wkh wms) v sk tC tF dC dF r p] = +formatWeather 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 far <- showWithColors show tF let sk' = formatSk sks (map toLower sk) parseTemplate [st, ss, y, m, d, h, wc, wa, wm, wk, wkh - , wms, v, sk, sk', cel, far + , wms, v, sk, sk', we, cel, far , show dC, show dF, show r , show p ] formatWeather _ _ = getConfigValue naString -- cgit v1.2.3