From 2063b0e8e29daf9df1be5ba86c98f2b0ff32061a Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+maverick1872@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:49:30 -0700 Subject: [PATCH 1/4] feat: add auto hide functionality to calendar widget --- calendar-widget/calendar.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua index a9fe02d3..82b37928 100644 --- a/calendar-widget/calendar.lua +++ b/calendar-widget/calendar.lua @@ -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( @@ -250,6 +267,10 @@ local function worker(user_args) end popup.visible = true + if user_args.auto_hide then + auto_hide_timer:start() + end + end end From 1be1419ab4df9a952a6c8285a9d86c7b5d93f615 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+maverick1872@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:53:09 -0700 Subject: [PATCH 2/4] fix: ensure timer is stopped if visibility is manually toggled --- calendar-widget/calendar.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua index 82b37928..9d7930b9 100644 --- a/calendar-widget/calendar.lua +++ b/calendar-widget/calendar.lua @@ -243,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')) From 5cf75b13d4269e86befdb2d8ccdb3acfeadfcae9 Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+maverick1872@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:53:50 -0700 Subject: [PATCH 3/4] fix: indentation fix --- calendar-widget/calendar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua index 9d7930b9..4eab52b0 100644 --- a/calendar-widget/calendar.lua +++ b/calendar-widget/calendar.lua @@ -243,7 +243,7 @@ local function worker(user_args) function calendar_widget.toggle() if popup.visible then - auto_hide_timer:stop() + 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')) From f421ed6c8916376a06d1eb1effb4a4e7128c0c3d Mon Sep 17 00:00:00 2001 From: Jonathon Terry <10217028+maverick1872@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:55:58 -0700 Subject: [PATCH 4/4] docs: document new user customization options --- calendar-widget/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/calendar-widget/README.md b/calendar-widget/README.md index b896baaa..c16930ae 100644 --- a/calendar-widget/README.md +++ b/calendar-widget/README.md @@ -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: