diff options
author | streetturtle <streetturtle@users.noreply.github.com> | 2021-05-26 15:22:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 15:22:11 -0400 |
commit | da0786fd30862ebc3c4173a55f3cb0c85959116c (patch) | |
tree | 3d32ac907529fa8270170956f5ba7345e58356ad /logout-popup-widget | |
parent | 11acce45064fc3917d65bc9ed0aedd1a6c1cda46 (diff) | |
parent | a3db496625e6541bb33b0ea5f2c3e1455f3bb921 (diff) |
Merge pull request #264 from Oozaku/fix-logout-popup
Add an alternative to change the color of the button's label
Diffstat (limited to 'logout-popup-widget')
-rw-r--r-- | logout-popup-widget/README.md | 1 | ||||
-rw-r--r-- | logout-popup-widget/logout-popup.lua | 22 |
2 files changed, 14 insertions, 9 deletions
diff --git a/logout-popup-widget/README.md b/logout-popup-widget/README.md index 9b83eed..5eec871 100644 --- a/logout-popup-widget/README.md +++ b/logout-popup-widget/README.md @@ -58,6 +58,7 @@ Then | `bg_color` | `beautiful.bg_normal` | The color the background of the | | `accent_color` | `beautiful.bg_focus` | The color of the buttons | | `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 | | `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 | diff --git a/logout-popup-widget/logout-popup.lua b/logout-popup-widget/logout-popup.lua index 4e52b50..4d85a8f 100644 --- a/logout-popup-widget/logout-popup.lua +++ b/logout-popup-widget/logout-popup.lua @@ -40,12 +40,12 @@ local phrase_widget = wibox.widget{ 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 { type = 'basic', icon = icon_name, - color = color, + color = accent_color, icon_size = icon_size, icon_margin = icon_margin, onclick = function() @@ -54,8 +54,11 @@ local function create_button(icon_name, action_name, color, onclick, icon_size, capi.keygrabber.stop() end } - button:connect_signal("mouse::enter", function() action:set_text(action_name) end) - button:connect_signal("mouse::leave", function() action:set_text(' ') end) + button:connect_signal("mouse::enter", + 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 end @@ -65,6 +68,7 @@ local function launch(args) local bg_color = args.bg_color or beautiful.bg_normal local accent_color = args.accent_color or beautiful.bg_focus 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 icon_size = args.icon_size or 40 local icon_margin = args.icon_margin or 16 @@ -86,11 +90,11 @@ local function launch(args) phrase_widget, { { - create_button('log-out', 'Log Out (l)', accent_color, onlogout, icon_size, icon_margin), - create_button('lock', 'Lock (k)', accent_color, onlock, icon_size, icon_margin), - create_button('refresh-cw', 'Reboot (r)', accent_color, onreboot, icon_size, icon_margin), - create_button('moon', 'Suspend (u)', accent_color, onsuspend, icon_size, icon_margin), - create_button('power', 'Power Off (s)', accent_color, onpoweroff, 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, label_color, onlock, 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, label_color, onsuspend, icon_size, icon_margin), + create_button('power', 'Power Off (s)', accent_color, label_color, onpoweroff, icon_size, icon_margin), id = 'buttons', spacing = 8, layout = wibox.layout.fixed.horizontal |