From 07dd7e3f9dd57530e16ac644e15521f37c60773b Mon Sep 17 00:00:00 2001 From: eylles Date: Thu, 27 Apr 2023 01:51:33 -0600 Subject: add hide on leave feature --- logout-popup-widget/README.md | 1 + logout-popup-widget/logout-popup.lua | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/logout-popup-widget/README.md b/logout-popup-widget/README.md index d95b692..b02f9b3 100644 --- a/logout-popup-widget/README.md +++ b/logout-popup-widget/README.md @@ -60,6 +60,7 @@ Then | `text_color` | `beautiful.fg_normal` | The color of text | | `label_color` | `beautiful.fg_normal` | The color of the button's label | | `phrases` | `{'Goodbye!'}` | The table with phrase(s) to show, if more than one provided, the phrase is chosen randomly. Leave empty (`{}`) to hide the phrase | +| `hide_on_leave` | `false` | If the popup should be hidden when the mouse leaves it | | `onlogout` | `function() awesome.quit() end` | Function which is called when the logout button is pressed | | `onlock` | `function() awful.spawn.with_shell("systemctl suspend") end` | Function which is called when the lock button is pressed | | `onreboot` | `function() awful.spawn.with_shell("reboot") end` | Function which is called when the reboot button is pressed | diff --git a/logout-popup-widget/logout-popup.lua b/logout-popup-widget/logout-popup.lua index efe6882..1462484 100644 --- a/logout-popup-widget/logout-popup.lua +++ b/logout-popup-widget/logout-popup.lua @@ -73,6 +73,7 @@ local function launch(args) local phrases = args.phrases or {'Goodbye!'} local icon_size = args.icon_size or 40 local icon_margin = args.icon_margin or 16 + local hide_on_leave = args.hide_on_leave or false local onlogout = args.onlogout or function () awesome.quit() end local onlock = args.onlock or function() awful.spawn.with_shell("i3lock") end @@ -124,6 +125,13 @@ local function launch(args) w.screen = mouse.screen w.visible = true + if hide_on_leave then + w:connect_signal("mouse::leave", function() + phrase_widget:set_text('') + capi.keygrabber.stop() + w.visible = false + end) + end awful.placement.centered(w) capi.keygrabber.run(function(_, key, event) -- cgit v1.2.3