Merge pull request #458 from Ryuno-Ki/preview-on-hover

feat: configuration option for hover forecast
This commit is contained in:
streetturtle 2024-11-09 13:49:22 -05:00 committed by GitHub
commit ca4ba9d24c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -18,6 +18,7 @@ following config parameters:
| units | `metric` | `metric` for celsius, `imperial` for fahrenheit | | 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 | | 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 | | 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_daily_forecast | false | Show forecast for next three days |
| show_hourly_forecast | false | Show hourly forecast section | | show_hourly_forecast | false | Show hourly forecast section |
| timeout | 120 | How often in seconds the widget refreshes | | timeout | 120 | How often in seconds the widget refreshes |

View File

@ -176,10 +176,10 @@ local function worker(user_args)
local both_units_widget = args.both_units_widget or false local both_units_widget = args.both_units_widget or false
local icon_pack_name = args.icons or 'weather-underground-icons' local icon_pack_name = args.icons or 'weather-underground-icons'
local icons_extension = args.icons_extension or '.png' 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_daily_forecast = args.show_daily_forecast or false
local show_hourly_forecast = args.show_hourly_forecast or false local show_hourly_forecast = args.show_hourly_forecast or false
local timeout = args.timeout or 120 local timeout = args.timeout or 120
local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/'
-- Forecast endpoint includes current. I could map show_daily_forecast to days here. -- Forecast endpoint includes current. I could map show_daily_forecast to days here.
-- Currently overfetching but only showing when opting in. -- Currently overfetching but only showing when opting in.
@ -640,12 +640,14 @@ local function worker(user_args)
end))) end)))
weather_widget:connect_signal("mouse::enter", function() weather_widget:connect_signal("mouse::enter", function()
weather_widget:set_bg(beautiful.bg_focus) if show_forecast_on_hover then
weather_popup:move_next_to(mouse.current_widget_geometry) weather_widget:set_bg(beautiful.bg_focus)
weather_popup:move_next_to(mouse.current_widget_geometry)
end
end) end)
weather_widget:connect_signal("mouse::leave", function() 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_widget:set_bg('#00000000')
weather_popup.visible = not weather_popup.visible weather_popup.visible = not weather_popup.visible
end end