From 3042e43749ed13994d464a56bad9118189f8d7b4 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Wed, 12 Jul 2017 23:37:49 +0100 Subject: Update weather widget config --- .config/awesome/lain | 2 +- .config/awesome/rc.lua | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) (limited to '.config/awesome') diff --git a/.config/awesome/lain b/.config/awesome/lain index 245ab7c..0b72341 160000 --- a/.config/awesome/lain +++ b/.config/awesome/lain @@ -1 +1 @@ -Subproject commit 245ab7c33a3261bd2730fdb054e888e31b26f1db +Subproject commit 0b72341bbe608726094a48671b680470c7d52db4 diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 8b2fdc8..6138c14 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -257,26 +257,32 @@ vicious.register(pkgwidget, vicious.widgets.pkg, "pkg: $1", 1800, "Debian") weatherwidget = lain.widget.weather({ city_id = 2964574, -- Dublin, Ireland units = "metric", - cnt = 1, - forecast_call = "curl -s 'http://api.openweathermap.org/data/2.5/forecast?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'", notification_preset = {fg = "#FFFFFF",bg = beautiful.bg_normal,position = "bottom_right",font = "dejavu sans mono 8" }, notification_text_fun = function(wn) - --local day = os.date("%A", wn["dt"]) + local city = wn["name"] + local country = wn["sys"]["country"] + local time = os.date("%H:%M",wn["dt"]) + local srise = os.date("%H:%M",wn["sys"]["sunrise"]) + local sset = os.date("%H:%M",wn["sys"]["sunset"]) local desc = wn["weather"][1]["description"] local temp = math.floor(wn["main"]["temp"]) - --local sunrise = tonumber(wn["sys"]["sunrise"]) - local pres = math.floor(wn["main"]["pressure"]) - local humi = math.floor(wn["main"]["humidity"]) - local wspe = math.floor(wn["wind"]["speed"]) - local wdeg = math.floor(wn["wind"]["deg"]) - local clou = math.floor(wn["clouds"]["all"]) local rain3h = 0 - if wn["rain"]["3h"] then + if wn["rain"] ~= nil then rain3h = math.floor(wn["rain"]["3h"]) end + local snow3h = 0 + if wn["snow"] ~= nil then + snow3h = math.floor(wn["snow"]["3h"]) + end + preci3h=rain3h+snow3h + local wspe = math.floor(wn["wind"]["speed"]) + local wdeg = math.floor(wn["wind"]["deg"]) + local humi = math.floor(wn["main"]["humidity"]) + local pres = math.floor(wn["main"]["pressure"]) + local clou = math.floor(wn["clouds"]["all"]) - -- format infos as you like, HTML text markup is allowed - return string.format("%s
temperature: %d°C
pressure: %dhPa
humidity: %d%%
wind: %d m/s at %d°
cloudliness: %d%%
rain: %d mm", desc, temp, pres, humi, wspe, wdeg, clou, rain3h) + return string.format("%s,%s @ %s
sunrise: %s
sunset: %s

%s
temperature: %d°C
precipitation: %d mm
wind: %d m/s at %d°
humidity: %d%%
pressure: %dhPa
cloudiness: %d%%", + city, country, time, srise, sset, desc, temp, preci3h, wspe, wdeg, humi, pres, clou) end, settings = function() units = math.floor(weather_now["main"]["temp"]) -- cgit v1.2.3