From fa4ff8b40d15799990ed6fc02a79d3a1b4a0c2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Wed, 30 Oct 2024 10:50:56 +0100 Subject: [PATCH] feat: configuration option for hover forecast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on a request this is now configurable. Signed-off-by: André Jaenisch --- weather-api-widget/README.md | 1 + weather-api-widget/weather.lua | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/weather-api-widget/README.md b/weather-api-widget/README.md index 9bfc5bc..519f66a 100644 --- a/weather-api-widget/README.md +++ b/weather-api-widget/README.md @@ -18,6 +18,7 @@ following config parameters: | units | `metric` | `metric` for celsius, `imperial` for fahrenheit | | icon_pack_name | `weather-underground-icons` | Name of the icon pack, could be `weather-underground-icon` or `VitalyGorbachev` or create your own, more details below | | icons_extension | `.png` | File extension of icons in the pack | +| show_forecast_on_hover | false | Show a forecast on hover, too | | show_daily_forecast | false | Show forecast for next three days | | show_hourly_forecast | false | Show hourly forecast section | | timeout | 120 | How often in seconds the widget refreshes | diff --git a/weather-api-widget/weather.lua b/weather-api-widget/weather.lua index 821b097..6bc720c 100644 --- a/weather-api-widget/weather.lua +++ b/weather-api-widget/weather.lua @@ -176,10 +176,10 @@ local function worker(user_args) local both_units_widget = args.both_units_widget or false local icon_pack_name = args.icons or 'weather-underground-icons' local icons_extension = args.icons_extension or '.png' + local show_forecast_on_hover = args.show_forecast_on_hover or false local show_daily_forecast = args.show_daily_forecast or false local show_hourly_forecast = args.show_hourly_forecast or false local timeout = args.timeout or 120 - local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' -- Forecast endpoint includes current. I could map show_daily_forecast to days here. -- Currently overfetching but only showing when opting in. @@ -640,12 +640,14 @@ local function worker(user_args) end))) weather_widget:connect_signal("mouse::enter", function() - weather_widget:set_bg(beautiful.bg_focus) - weather_popup:move_next_to(mouse.current_widget_geometry) + if show_forecast_on_hover then + weather_widget:set_bg(beautiful.bg_focus) + weather_popup:move_next_to(mouse.current_widget_geometry) + end end) weather_widget:connect_signal("mouse::leave", function() - if weather_popup.visible then + if show_forecast_on_hover and weather_popup.visible then weather_widget:set_bg('#00000000') weather_popup.visible = not weather_popup.visible end