Merge pull request #402 from eylles/hide-logout-on-mouse-leave

add hide on leave feature
This commit is contained in:
streetturtle 2023-10-16 18:19:29 -04:00 committed by GitHub
commit 4381a89ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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 |

View File

@ -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)