Skip to content

Commit

Permalink
Merge pull request #452 from maverick1872/patch-1
Browse files Browse the repository at this point in the history
feat(calendar): add auto hide functionality
  • Loading branch information
streetturtle committed Aug 9, 2024
2 parents effc902 + f421ed6 commit 68ddbd9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions calendar-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
| radius | 8 | The popup radius |
| start_sunday | false | Start the week on Sunday |
| week_numbers | false | Show ISO week numbers (Mon = first) |
| auto_hide | false | Auto hide the popup after timeout |
| timeout | 2 | Auto hide timeout length |

- themes:

Expand Down
22 changes: 22 additions & 0 deletions calendar-widget/calendar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ local function worker(user_args)
border_color = calendar_themes[theme].border,
widget = cal
}

local auto_hide_timer = gears.timer({
timeout = user_args.timeout or 2,
single_shot = true,
callback = function()
calendar_widget.toggle()
end,
})

popup:connect_signal("mouse::leave", function()
if user_args.auto_hide then
auto_hide_timer:again()
end
end)
popup:connect_signal("mouse::enter", function()
auto_hide_timer:stop()
end)

popup:buttons(
awful.util.table.join(
Expand All @@ -226,6 +243,7 @@ local function worker(user_args)
function calendar_widget.toggle()

if popup.visible then
auto_hide_timer:stop()
-- to faster render the calendar refresh it and just hide
cal:set_date(nil) -- the new date is not set without removing the old one
cal:set_date(os.date('*t'))
Expand All @@ -250,6 +268,10 @@ local function worker(user_args)
end

popup.visible = true
if user_args.auto_hide then
auto_hide_timer:start()
end


end
end
Expand Down

0 comments on commit 68ddbd9

Please sign in to comment.