aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2013-12-15 02:48:00 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2013-12-15 17:47:49 +0100
commit7961ca145479e364fe64ec082e24545bd0f3c4bb (patch)
tree2bdd1c50b361e866fb74775d1a792e9093d0e481 /widgets
parentdc556e5415ee1d1b3b74508e016fb1693d55a311 (diff)
downloadvicious-legacy-7961ca145479e364fe64ec082e24545bd0f3c4bb.tar.xz
weather: add support for dew point
Signed-off-by: Jonathan McCrohan <jmccrohan@gmail.com> Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/weather.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/widgets/weather.lua b/widgets/weather.lua
index 356f32f..029df7e 100644
--- a/widgets/weather.lua
+++ b/widgets/weather.lua
@@ -28,6 +28,8 @@ local _weather = {
["{weather}"] = "N/A",
["{tempf}"] = "N/A",
["{tempc}"] = "N/A",
+ ["{dewf}"] = "N/A",
+ ["{dewc}"] = "N/A",
["{humid}"] = "N/A",
["{press}"] = "N/A"
}
@@ -58,6 +60,8 @@ local function worker(format, warg)
string.match(ws, "Weather:[%s](.-)[%c]") or _weather["{weather}"]
_weather["{tempf}"] = -- Temperature in fahrenheit
string.match(ws, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"]
+ _weather["{dewf}"] = -- Dew Point in fahrenheit
+ string.match(ws, "Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{dewf}"]
_weather["{humid}"] = -- Relative humidity in percent
string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"]
_weather["{press}"] = -- Pressure in hPa
@@ -71,6 +75,10 @@ local function worker(format, warg)
if _weather["{tempf}"] ~= "N/A" then
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
+ end -- Dew Point in °C if °F was available
+ if _weather["{dewf}"] ~= "N/A" then
+ _weather["{dewf}"] = tonumber(_weather["{dewf}"])
+ _weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
end -- Capitalize some stats so they don't look so out of place
if _weather["{sky}"] ~= "N/A" then
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])