Dump nixos config after scrubing
|
|
@ -0,0 +1,91 @@
|
|||
# Logout Popup Widget
|
||||
|
||||
Widget which allows performing lock, reboot, log out, power off and sleep actions. It can be called either by a shortcut, or by clicking on a widget in wibar.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/streetturtle/awesome-wm-widgets/raw/master/logout-popup-widget/screenshot.gif" alt="screenshot">
|
||||
</p>
|
||||
|
||||
When the widget is shown, following shortcuts can be used:
|
||||
- <kbd>Escape</kbd> - hide widget
|
||||
- <kbd>s</kbd> - shutdown
|
||||
- <kbd>r</kbd> - reboot
|
||||
- <kbd>u</kbd> - suspend
|
||||
- <kbd>k</kbd> - lock
|
||||
- <kbd>l</kbd> - log out
|
||||
|
||||
# Installation
|
||||
|
||||
Clone this (if not cloned yet) and the [awesome-buttons](https://github.com/streetturtle/awesome-buttons) repos under **./.config/awesome/**
|
||||
|
||||
```bash
|
||||
cd ./.config/awesome/
|
||||
git clone https://github.com/streetturtle/awesome-wm-widgets
|
||||
git clone https://github.com/streetturtle/awesome-buttons
|
||||
```
|
||||
Then
|
||||
|
||||
- to show by a shortcut - define a shortcut in `globalkeys`:
|
||||
|
||||
```lua
|
||||
local logout_popup = require("awesome-wm-widgets.logout-popup-widget.logout-popup")
|
||||
...
|
||||
globalkeys = gears.table.join(
|
||||
...
|
||||
awful.key({ modkey }, "l", function() logout_popup.launch() end, {description = "Show logout screen", group = "custom"}),
|
||||
```
|
||||
|
||||
- to show by clicking on a widget in wibar - add widget to the wibar:
|
||||
|
||||
```lua
|
||||
local logout_popup = require("awesome-wm-widgets.logout-popup-widget.logout-popup")
|
||||
|
||||
s.mytasklist, -- Middle widget
|
||||
{ -- Right widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
...
|
||||
logout_popup.widget{},
|
||||
...
|
||||
```
|
||||
|
||||
# Customisation
|
||||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `icon` | `power.svg` | If used as widget - the path to the widget's icon |
|
||||
| `icon_size` | 40 | Size of the icon |
|
||||
| `icon_margin` | 16 | Margin around the icon |
|
||||
| `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 |
|
||||
| `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 |
|
||||
| `onsuspend` | `function() awful.spawn.with_shell("systemctl suspend") end` | Function which is called when the suspend button is pressed |
|
||||
| `onpoweroff` | `function() awful.spawn.with_shell("shutdown now") end` | Function which is called when the poweroff button is pressed |
|
||||
| `onlogout_key` | <kbd>l</kbd> | Keybinding to execute the logout function |
|
||||
| `onlock_key` | <kbd>k</kbd> | Keybinding to execute the lock function |
|
||||
| `onreboot_key` | <kbd>r</kbd> | Keybinding to execute the reboot function |
|
||||
| `onsuspend_key` | <kbd>u</kbd> | Keybinding to execute the suspend function |
|
||||
| `onpoweroff_key` | <kbd>s</kbd> | Keybinding to execute the poweroff function |
|
||||
| `ignore_case` | true | Ignore if CAPS LOCK is enabled |
|
||||
|
||||
Some color themes for inspiration:
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
```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!"},
|
||||
}
|
||||
```
|
||||
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
|
@ -0,0 +1,221 @@
|
|||
-------------------------------------------------
|
||||
-- Logout widget for Awesome Window Manager
|
||||
-- More details could be found here:
|
||||
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/logout-widget
|
||||
|
||||
-- @author Pavel Makhov
|
||||
-- @copyright 2020 Pavel Makhov
|
||||
-------------------------------------------------
|
||||
|
||||
local awful = require("awful")
|
||||
local capi = {keygrabber = keygrabber }
|
||||
local wibox = require("wibox")
|
||||
local gears = require("gears")
|
||||
local beautiful = require("beautiful")
|
||||
local awesomebuttons = require("awesome-buttons.awesome-buttons")
|
||||
|
||||
|
||||
local HOME_DIR = os.getenv("HOME")
|
||||
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/logout-popup-widget'
|
||||
|
||||
|
||||
local w = wibox {
|
||||
bg = beautiful.fg_normal,
|
||||
max_widget_size = 500,
|
||||
ontop = true,
|
||||
height = 200,
|
||||
width = 400,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 8)
|
||||
end
|
||||
}
|
||||
|
||||
local action = wibox.widget {
|
||||
text = ' ',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
local phrase_widget = wibox.widget{
|
||||
align = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
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 = accent_color,
|
||||
icon_size = icon_size,
|
||||
icon_margin = icon_margin,
|
||||
onclick = function()
|
||||
onclick()
|
||||
w.visible = false
|
||||
capi.keygrabber.stop()
|
||||
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
|
||||
|
||||
local function launch(args)
|
||||
args = args or {}
|
||||
|
||||
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
|
||||
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-fancy") end
|
||||
local onreboot = args.onreboot or function() awful.spawn.with_shell("reboot") end
|
||||
local onsuspend = args.onsuspend or function() awful.spawn.easy_async_with_shell("i3lock-fancy",
|
||||
function()
|
||||
-- awful.spawn.with_shell("systemctl hybrid-sleep")
|
||||
awful.spawn.with_shell("systemctl suspend")
|
||||
end)
|
||||
end
|
||||
local onpoweroff = args.onpoweroff or function() awful.spawn.with_shell("shutdown now") end
|
||||
|
||||
local onlogout_key = args.onlogout_key or 'l'
|
||||
local onlock_key = args.onlock_key or 'k'
|
||||
local onreboot_key = args.onreboot_key or 'r'
|
||||
local onsuspend_key = args.onsuspend_key or 'u'
|
||||
local onpoweroff_key = args.onpoweroff_key or 's'
|
||||
local all_keys = onlogout_key .. onlock_key .. onreboot_key .. onsuspend_key .. onpoweroff_key
|
||||
|
||||
local ignore_case = args.ignore_case or true
|
||||
|
||||
w:set_bg(bg_color)
|
||||
if #phrases > 0 then
|
||||
phrase_widget:set_markup(
|
||||
'<span color="'.. text_color .. '" size="20000">' .. phrases[ math.random( #phrases ) ] .. '</span>')
|
||||
end
|
||||
|
||||
w:setup {
|
||||
{
|
||||
phrase_widget,
|
||||
{
|
||||
{
|
||||
create_button('log-out', 'Log Out (' .. onlogout_key .. ')',
|
||||
accent_color, label_color, onlogout, icon_size, icon_margin),
|
||||
create_button('lock', 'Lock (' .. onlock_key .. ')',
|
||||
accent_color, label_color, onlock, icon_size, icon_margin),
|
||||
create_button('refresh-cw', 'Reboot (' .. onreboot_key .. ')',
|
||||
accent_color, label_color, onreboot, icon_size, icon_margin),
|
||||
create_button('moon', 'Suspend (' .. onsuspend_key .. ')',
|
||||
accent_color, label_color, onsuspend, icon_size, icon_margin),
|
||||
create_button('power', 'Power Off (' .. onpoweroff_key .. ')',
|
||||
accent_color, label_color, onpoweroff, icon_size, icon_margin),
|
||||
id = 'buttons',
|
||||
spacing = 8,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
valign = 'center',
|
||||
layout = wibox.container.place
|
||||
},
|
||||
{
|
||||
action,
|
||||
halign = 'center',
|
||||
layout = wibox.container.place
|
||||
},
|
||||
spacing = 32,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
id = 'a',
|
||||
shape_border_width = 1,
|
||||
valign = 'center',
|
||||
layout = wibox.container.place
|
||||
}
|
||||
|
||||
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)
|
||||
if event == "release" then return end
|
||||
if key then
|
||||
if key == 'Escape' then
|
||||
phrase_widget:set_text('')
|
||||
capi.keygrabber.stop()
|
||||
w.visible = false
|
||||
else
|
||||
if ignore_case then
|
||||
key = string.lower(key)
|
||||
onlogout_key = string.lower(onlogout_key)
|
||||
onlock_key = string.lower(onlock_key)
|
||||
onreboot_key = string.lower(onreboot_key)
|
||||
onsuspend_key = string.lower(onsuspend_key)
|
||||
onpoweroff_key = string.lower(onpoweroff_key)
|
||||
all_keys = string.lower(all_keys)
|
||||
end
|
||||
|
||||
if key == onpoweroff_key then onpoweroff()
|
||||
elseif key == onreboot_key then onreboot()
|
||||
elseif key == onsuspend_key then onsuspend()
|
||||
elseif key == onlock_key then onlock()
|
||||
elseif key == onlogout_key then onlogout()
|
||||
end
|
||||
|
||||
if string.match(all_keys, key) then
|
||||
phrase_widget:set_text('')
|
||||
capi.keygrabber.stop()
|
||||
w.visible = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function widget(args)
|
||||
local icon = args.icon or WIDGET_DIR .. '/power.svg'
|
||||
|
||||
local res = wibox.widget {
|
||||
{
|
||||
{
|
||||
image = icon,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
margins = 4,
|
||||
layout = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
}
|
||||
|
||||
res:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button({}, 1, function()
|
||||
if w.visible then
|
||||
phrase_widget:set_text('')
|
||||
capi.keygrabber.stop()
|
||||
w.visible = false
|
||||
else
|
||||
launch(args)
|
||||
end
|
||||
end)
|
||||
))
|
||||
|
||||
return res
|
||||
|
||||
end
|
||||
|
||||
return {
|
||||
launch = launch,
|
||||
widget = widget
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ECEFF4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-power"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>
|
||||
|
After Width: | Height: | Size: 303 B |
|
After Width: | Height: | Size: 436 KiB |
|
After Width: | Height: | Size: 127 KiB |