From ce04667af3ec0f9704e806af400e543863780095 Mon Sep 17 00:00:00 2001
From: streetturtle
Date: Tue, 29 Sep 2020 22:23:02 -0400
Subject: [logout] add shorcuts
---
logout-widget/README.md | 12 +++++++++++-
logout-widget/logout-dracula.png | Bin 0 -> 44660 bytes
logout-widget/logout.lua | 33 ++++++++++++++++++++++++---------
logout-widget/screenshot.gif | Bin 172152 -> 446468 bytes
4 files changed, 35 insertions(+), 10 deletions(-)
create mode 100644 logout-widget/logout-dracula.png
diff --git a/logout-widget/README.md b/logout-widget/README.md
index a430258..7d1673d 100644
--- a/logout-widget/README.md
+++ b/logout-widget/README.md
@@ -6,6 +6,14 @@ Widget which allows to perform lock, reboot, log out, power off and sleep action
+When the widget is shown, following shortcuts can be used:
+ - Escape - hide widget
+ - s - shutdown
+ - r - reboot
+ - u - suspend
+ - k - lock
+ - l - log out
+
# Installation
Clone this (if not cloned yet) and the [awesome-buttons](https://github.com/streetturtle/awesome-buttons) repos under **./.config/awesome/**
@@ -50,7 +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 |
-| `phrases` | `{'Goodbye!'}` | The table with phrase(s) to show, if more than one provided, the phrase is chosen randomly |
+| `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 |
| `onreboot` | `function() awful.spawn.with_shell("reboot") end` | Function which is called when the reboot button is pressed |
@@ -62,12 +70,14 @@ Some color themes for inspiration:
![nord](./logout-nord.png)
![outrun](./logout-outrun.png)
![dark](./logout-dark.png)
+![dracula](./logout-dracula.png)
```lua
logout.launch{
bg_color = "#261447", accent_color = "#ff4365", text_color = '#f706cf', icon_size = 40, icon_margin = 16, -- outrun
-- bg_color = "#0b0c10", accent_color = "#1f2833", text_color = '#66fce1', -- dark
-- bg_color = "#3B4252", accent_color = "#88C0D0", text_color = '#D8DEE9', -- nord
+ -- bg_color = "#282a36", accent_color = "#ff79c6", phrases = {}, -- dracula, no phrase
phrases = {"exit(0)", "Don't forget to be awesome.", "Yippee ki yay!"},
}
```
diff --git a/logout-widget/logout-dracula.png b/logout-widget/logout-dracula.png
new file mode 100644
index 0000000..3c61c46
Binary files /dev/null and b/logout-widget/logout-dracula.png differ
diff --git a/logout-widget/logout.lua b/logout-widget/logout.lua
index 3468673..b8835a6 100644
--- a/logout-widget/logout.lua
+++ b/logout-widget/logout.lua
@@ -74,18 +74,20 @@ local function launch(args)
local onpoweroff = args.onpoweroff or function() awful.spawn.with_shell("shutdown now") end
w:set_bg(bg_color)
- phrase_widget:set_markup('' .. phrases[ math.random( #phrases ) ] .. '')
+ if #phrases > 0 then
+ phrase_widget:set_markup('' .. phrases[ math.random( #phrases ) ] .. '')
+ end
w:setup {
{
phrase_widget,
{
{
- create_button('log-out', 'Log Out', accent_color, onlogout, icon_size, icon_margin),
- create_button('lock', 'Lock', accent_color, onlock, icon_size, icon_margin),
- create_button('refresh-cw', 'Reboot', accent_color, onreboot, icon_size, icon_margin),
- create_button('moon', 'Suspend', accent_color, onsuspend, icon_size, icon_margin),
- create_button('power', 'Power Off', accent_color, onpoweroff, icon_size, icon_margin),
+ 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),
id = 'buttons',
spacing = 8,
layout = wibox.layout.fixed.horizontal
@@ -113,9 +115,22 @@ local function launch(args)
capi.keygrabber.run(function(_, key, event)
if event == "release" then return end
if key then
- phrase_widget:set_text('')
- capi.keygrabber.stop()
- w.visible = false
+ if key == 'Escape' then
+ phrase_widget:set_text('')
+ capi.keygrabber.stop()
+ w.visible = false
+ elseif key == 's' then onpoweroff()
+ elseif key == 'r' then onreboot()
+ elseif key == 'u' then onsuspend()
+ elseif key == 'k' then onlock()
+ elseif key == 'l' then onlogout()
+ end
+
+ if key == 'Escape' or string.match("srukl", key) then
+ phrase_widget:set_text('')
+ capi.keygrabber.stop()
+ w.visible = false
+ end
end
end)
end
diff --git a/logout-widget/screenshot.gif b/logout-widget/screenshot.gif
index 8fcf9ab..4975c19 100644
Binary files a/logout-widget/screenshot.gif and b/logout-widget/screenshot.gif differ
--
cgit v1.2.3