Skip to content

Commit

Permalink
Merge pull request #458 from Ryuno-Ki/preview-on-hover
Browse files Browse the repository at this point in the history
feat: configuration option for hover forecast
  • Loading branch information
streetturtle authored Nov 9, 2024
2 parents 81cd341 + fa4ff8b commit ca4ba9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions weather-api-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
10 changes: 6 additions & 4 deletions weather-api-widget/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ca4ba9d

Please sign in to comment.