[logout] some improvements
This commit is contained in:
parent
fed33cc3b4
commit
402ebd0480
|
@ -0,0 +1,15 @@
|
||||||
|
# Logout widget
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Clone repo (if not cloned yet) under ~/.config/awesome, then
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local logout = require("awesome-wm-widgets.experiments.logout-widget.logout")
|
||||||
|
|
||||||
|
-- define a shorcut in globalkey
|
||||||
|
awful.key({ modkey }, "l", function() logout.launch() end, {description = "Show logout screen", group = "custom"}),
|
||||||
|
```
|
||||||
|
|
||||||
|
# Customisation
|
||||||
|
|
|
@ -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-lock"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>
|
After Width: | Height: | Size: 316 B |
|
@ -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-log-out"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path><polyline points="16 17 21 12 16 7"></polyline><line x1="21" y1="12" x2="9" y2="12"></line></svg>
|
After Width: | Height: | Size: 362 B |
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
|
After Width: | Height: | Size: 276 B |
|
@ -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 |
|
@ -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-refresh-cw"><polyline points="23 4 23 10 17 10"></polyline><polyline points="1 20 1 14 7 14"></polyline><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path></svg>
|
After Width: | Height: | Size: 395 B |
|
@ -8,79 +8,103 @@
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local gfs = require("gears.filesystem")
|
local capi = {keygrabber = keygrabber }
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
local fancybuttons = require("awesome-buttons.awesome-buttons")
|
||||||
|
|
||||||
local ICON = '/usr/share/icons/Papirus-Light/32x32/apps/spotify-linux-48x48.svg'
|
|
||||||
|
|
||||||
local spotify_shell = awful.widget.prompt()
|
local HOME_DIR = os.getenv("HOME")
|
||||||
|
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/experiments/logout-widget'
|
||||||
|
local ICONS_DIR = WIDGET_DIR .. '/icons/'
|
||||||
|
|
||||||
|
|
||||||
local w = wibox {
|
local w = wibox {
|
||||||
bg = '#1e252c',
|
bg = beautiful.fg_normal,
|
||||||
border_width = 1,
|
|
||||||
border_color = '#84bd00',
|
|
||||||
max_widget_size = 500,
|
max_widget_size = 500,
|
||||||
ontop = true,
|
ontop = true,
|
||||||
height = 400,
|
height = 200,
|
||||||
width = 250,
|
width = 400,
|
||||||
shape = function(cr, width, height)
|
shape = function(cr, width, height)
|
||||||
gears.shape.rounded_rect(cr, width, height, 3)
|
gears.shape.rounded_rect(cr, width, height, 8)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
w:setup {
|
local action = wibox.widget {
|
||||||
|
text = ' ',
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local function create_button(icon_name, action_name, color, onclick)
|
||||||
|
|
||||||
|
local button = fancybuttons.with_icon{ type = 'basic', shape = 'circle', icon = ICONS_DIR .. icon_name, color = color, onclick = onclick }
|
||||||
|
button:connect_signal("mouse::enter", function(c) action:set_text(action_name) end)
|
||||||
|
button:connect_signal("mouse::leave", function(c) action:set_text(' ') end)
|
||||||
|
return button
|
||||||
|
end
|
||||||
|
|
||||||
|
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 phrases = args.phrases or {'Goodbye!'}
|
||||||
|
|
||||||
|
local onlogout = args.onlogout or function () awesome.quit() end
|
||||||
|
local onlock = args.onlock
|
||||||
|
local onreboot = args.onreboot
|
||||||
|
local onsuspend = args.onsuspend
|
||||||
|
local onpoweroff = args.onpoweroff or function () awful.spawn.with_shell("shutdown now") end
|
||||||
|
|
||||||
|
w:set_bg(bg_color)
|
||||||
|
|
||||||
|
w:setup {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
{
|
markup = '<span color="'.. text_color .. '" size="20000">' .. phrases[ math.random( #phrases ) ] .. '</span>',
|
||||||
image = ICON,
|
align = 'center',
|
||||||
widget = wibox.widget.imagebox,
|
widget = wibox.widget.textbox
|
||||||
resize = false
|
|
||||||
},
|
|
||||||
id = 'icon',
|
|
||||||
top = 9,
|
|
||||||
left = 10,
|
|
||||||
layout = wibox.container.margin
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
layout = wibox.container.margin,
|
{
|
||||||
left = 10,
|
create_button('log-out.svg', 'Log Out', accent_color, onlogout),
|
||||||
spotify_shell,
|
create_button('lock.svg', 'Lock', accent_color, onlock),
|
||||||
},
|
create_button('refresh-cw.svg', 'Reboot', accent_color, onreboot),
|
||||||
id = 'left',
|
create_button('moon.svg', 'Suspend', accent_color, onsuspend),
|
||||||
|
create_button('power.svg', 'Power Off', accent_color, onpoweroff),
|
||||||
|
id = 'buttons',
|
||||||
|
spacing = 8,
|
||||||
layout = wibox.layout.fixed.horizontal
|
layout = wibox.layout.fixed.horizontal
|
||||||
},
|
},
|
||||||
{
|
valigh = 'center',
|
||||||
image = '/usr/share/icons/Arc/actions/symbolic/system-shutdown-symbolic.svg',
|
layout = wibox.container.place
|
||||||
widget = wibox.widget.imagebox,
|
|
||||||
resize = false,
|
|
||||||
opacity = 0.2,
|
|
||||||
set_hover = function(self, opacity)
|
|
||||||
self.opacity = opacity
|
|
||||||
self.image = '/usr/share/icons/Arc/actions/symbolic/system-shutdown-symbolic.svg'
|
|
||||||
end
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
action,
|
||||||
|
haligh = 'center',
|
||||||
|
layout = wibox.container.place
|
||||||
|
},
|
||||||
|
spacing = 32,
|
||||||
layout = wibox.layout.fixed.vertical
|
layout = wibox.layout.fixed.vertical
|
||||||
}
|
},
|
||||||
|
id = 'a',
|
||||||
|
shape_border_width = 1,
|
||||||
|
valigh = 'center',
|
||||||
|
layout = wibox.container.place
|
||||||
|
}
|
||||||
|
|
||||||
local function launch()
|
|
||||||
w.visible = true
|
w.visible = true
|
||||||
|
|
||||||
awful.placement.top(w, { margins = {top = 40}, parent = awful.screen.focused()})
|
awful.placement.centered(w)
|
||||||
awful.prompt.run{
|
capi.keygrabber.run(function(_, key, event)
|
||||||
prompt = "<b>Spotify Shell</b>: ",
|
if event == "release" then return end
|
||||||
bg_cursor = '#84bd00',
|
if key then
|
||||||
textbox = spotify_shell.widget,
|
capi.keygrabber.stop()
|
||||||
history_path = gfs.get_dir('cache') .. '/spotify_history',
|
|
||||||
exe_callback = function(input_text)
|
|
||||||
if not input_text or #input_text == 0 then return end
|
|
||||||
awful.spawn("sp " .. input_text)
|
|
||||||
end,
|
|
||||||
done_callback = function()
|
|
||||||
w.visible = false
|
w.visible = false
|
||||||
end
|
end
|
||||||
}
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue