diff --git a/widget/alsa.lua b/widget/alsa.lua index cd095e2..90fd8fe 100644 --- a/widget/alsa.lua +++ b/widget/alsa.lua @@ -37,7 +37,7 @@ local function factory(args) helpers.async(format_cmd, function(mixer) local l,s = string.match(mixer, "([%d]+)%%.*%[([%l]*)") if alsa.last.level ~= l or alsa.last.status ~= s then - volume_now = { level = l, status = s } + volume_now = { level = tonumber(l), status = s } widget = alsa.widget settings() alsa.last = volume_now diff --git a/widget/weather.lua b/widget/weather.lua index 24d7d73..598b692 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -23,7 +23,9 @@ local tonumber = tonumber local function factory(args) args = args or {} - local weather = { widget = args.widget or wibox.widget.textbox() } + local weather = { widget = args.widget or wibox.widget.textbox(), + currentWeather = {}, + } local APPID = args.APPID -- mandatory local timeout = args.timeout or 60 * 15 -- 15 min local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'" @@ -42,9 +44,21 @@ local function factory(args) local desc = wn["weather"][1]["description"] return string.format("%s: %s, %d - %d ", day, desc, tmin, tmax) end + local notification_text_currentWeather = args.notification_text_currentWeather or + function (wn) + return string.format( + "%s\n- %s\n- Temp: %0.1f°C\n- Feels like: %0.1f°C\n- Pressure: %d\n- Humidity: %d%%\n", + wn["name"], + wn["weather"][1]["description"], + wn["main"]["temp"], + wn["main"]["feels_like"], + wn["main"]["pressure"], + wn["main"]["humidity"]) + end local weather_na_markup = args.weather_na_markup or " N/A " local followtag = args.followtag or false local showpopup = args.showpopup or "on" + local showCurrentWeatherNotification = args.showCurrentWeatherNotification or "off" local settings = args.settings or function() end weather.widget:set_markup(weather_na_markup) @@ -95,6 +109,12 @@ local function factory(args) if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then weather.notification_text = "" + + if showCurrentWeatherNotification == "on" then + weather.notification_text = weather.notification_text .. + notification_text_currentWeather(weather.currentWeather) + end + for i = 1, weather_now["cnt"], weather_now["cnt"]//cnt do weather.notification_text = weather.notification_text .. notification_text_fun(weather_now["list"][i]) @@ -126,6 +146,10 @@ local function factory(args) weather.icon_path = icons_path .. icon .. ".png" widget = weather.widget + + -- Store current weather for notification popup + weather.currentWeather = weather_now + settings() else weather.icon_path = icons_path .. "na.png"