Skip to content

Commit

Permalink
Merge pull request #402 from eylles/hide-logout-on-mouse-leave
Browse files Browse the repository at this point in the history
add hide on leave feature
  • Loading branch information
streetturtle authored Oct 16, 2023
2 parents 9c6dc31 + 4b04825 commit 4381a89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions logout-popup-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
8 changes: 8 additions & 0 deletions logout-popup-widget/logout-popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4381a89

Please sign in to comment.