Skip to content

Commit 68ddbd9

Browse files
authored
Merge pull request #452 from maverick1872/patch-1
feat(calendar): add auto hide functionality
2 parents effc902 + f421ed6 commit 68ddbd9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

calendar-widget/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
1414
| radius | 8 | The popup radius |
1515
| start_sunday | false | Start the week on Sunday |
1616
| week_numbers | false | Show ISO week numbers (Mon = first) |
17+
| auto_hide | false | Auto hide the popup after timeout |
18+
| timeout | 2 | Auto hide timeout length |
1719

1820
- themes:
1921

calendar-widget/calendar.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,23 @@ local function worker(user_args)
203203
border_color = calendar_themes[theme].border,
204204
widget = cal
205205
}
206+
207+
local auto_hide_timer = gears.timer({
208+
timeout = user_args.timeout or 2,
209+
single_shot = true,
210+
callback = function()
211+
calendar_widget.toggle()
212+
end,
213+
})
214+
215+
popup:connect_signal("mouse::leave", function()
216+
if user_args.auto_hide then
217+
auto_hide_timer:again()
218+
end
219+
end)
220+
popup:connect_signal("mouse::enter", function()
221+
auto_hide_timer:stop()
222+
end)
206223

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

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

252270
popup.visible = true
271+
if user_args.auto_hide then
272+
auto_hide_timer:start()
273+
end
274+
253275

254276
end
255277
end

0 commit comments

Comments
 (0)