Merge pull request #264 from Oozaku/fix-logout-popup

Add an alternative to change the color of the button's label
This commit is contained in:
streetturtle 2021-05-26 15:22:11 -04:00 committed by GitHub
commit da0786fd30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View File

@ -58,6 +58,7 @@ Then
| `bg_color` | `beautiful.bg_normal` | The color the background of the | | `bg_color` | `beautiful.bg_normal` | The color the background of the |
| `accent_color` | `beautiful.bg_focus` | The color of the buttons | | `accent_color` | `beautiful.bg_focus` | The color of the buttons |
| `text_color` | `beautiful.fg_normal` | The color of text | | `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 | | `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 |
| `onlogout` | `function() awesome.quit() end` | Function which is called when the logout button is pressed | | `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 | | `onlock` | `function() awful.spawn.with_shell("systemctl suspend") end` | Function which is called when the lock button is pressed |

View File

@ -40,12 +40,12 @@ local phrase_widget = wibox.widget{
widget = wibox.widget.textbox widget = wibox.widget.textbox
} }
local function create_button(icon_name, action_name, color, onclick, icon_size, icon_margin) local function create_button(icon_name, action_name, accent_color, label_color, onclick, icon_size, icon_margin)
local button = awesomebuttons.with_icon { local button = awesomebuttons.with_icon {
type = 'basic', type = 'basic',
icon = icon_name, icon = icon_name,
color = color, color = accent_color,
icon_size = icon_size, icon_size = icon_size,
icon_margin = icon_margin, icon_margin = icon_margin,
onclick = function() onclick = function()
@ -54,8 +54,11 @@ local function create_button(icon_name, action_name, color, onclick, icon_size,
capi.keygrabber.stop() capi.keygrabber.stop()
end end
} }
button:connect_signal("mouse::enter", function() action:set_text(action_name) end) button:connect_signal("mouse::enter",
button:connect_signal("mouse::leave", function() action:set_text(' ') end) function() action:set_markup('<span color="' .. label_color .. '">' .. action_name .. '</span>') end)
button:connect_signal("mouse::leave", function() action:set_markup('<span> </span>') end)
return button return button
end end
@ -65,6 +68,7 @@ local function launch(args)
local bg_color = args.bg_color or beautiful.bg_normal local bg_color = args.bg_color or beautiful.bg_normal
local accent_color = args.accent_color or beautiful.bg_focus local accent_color = args.accent_color or beautiful.bg_focus
local text_color = args.text_color or beautiful.fg_normal local text_color = args.text_color or beautiful.fg_normal
local label_color = args.label_color or beautiful.fg_focus
local phrases = args.phrases or {'Goodbye!'} local phrases = args.phrases or {'Goodbye!'}
local icon_size = args.icon_size or 40 local icon_size = args.icon_size or 40
local icon_margin = args.icon_margin or 16 local icon_margin = args.icon_margin or 16
@ -86,11 +90,11 @@ local function launch(args)
phrase_widget, phrase_widget,
{ {
{ {
create_button('log-out', 'Log Out (l)', accent_color, onlogout, icon_size, icon_margin), create_button('log-out', 'Log Out (l)', accent_color, label_color, onlogout, icon_size, icon_margin),
create_button('lock', 'Lock (k)', accent_color, onlock, icon_size, icon_margin), create_button('lock', 'Lock (k)', accent_color, label_color, onlock, icon_size, icon_margin),
create_button('refresh-cw', 'Reboot (r)', accent_color, onreboot, icon_size, icon_margin), create_button('refresh-cw', 'Reboot (r)', accent_color, label_color, onreboot, icon_size, icon_margin),
create_button('moon', 'Suspend (u)', accent_color, onsuspend, icon_size, icon_margin), create_button('moon', 'Suspend (u)', accent_color, label_color, onsuspend, icon_size, icon_margin),
create_button('power', 'Power Off (s)', accent_color, onpoweroff, icon_size, icon_margin), create_button('power', 'Power Off (s)', accent_color, label_color, onpoweroff, icon_size, icon_margin),
id = 'buttons', id = 'buttons',
spacing = 8, spacing = 8,
layout = wibox.layout.fixed.horizontal layout = wibox.layout.fixed.horizontal