1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
local awful = require "awful"
local phosphor = require "assets.phosphor"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
local rubato = require "lib.rubato"
local wibox = require "wibox"
local function create_button(title, icon, color, exec)
return wibox.widget {
widget = wibox.container.background,
shape = qvars.shape,
{
widget = wibox.container.margin,
margins = qvars.big_padding,
{
qui.styled {
widget = wibox.container.background,
border_color = color,
{
widget = wibox.container.margin,
margins = qvars.big_padding,
qui.icon {
widget = {
forced_height = qvars.char_height * 4 - qvars.big_padding * 2,
forced_width = qvars.char_height * 4 - qvars.big_padding * 2,
},
icon = icon,
color = color,
},
},
},
{
widget = wibox.container.place,
{
widget = wibox.widget.textbox,
text = title,
},
},
layout = wibox.layout.fixed.vertical,
spacing = qvars.big_padding,
exec = exec,
},
},
select = function(self)
self.bg = qvars.colors.black
end,
}
end
local powermenu = {}
local toggled = false
screen.connect_signal("request::desktop_decoration", function(s)
powermenu._widget = qui.popup {
ontop = true,
visible = false,
minimum_width = s.geometry.width,
minimum_height = s.geometry.height,
bg = qvars.colors.bg .. "ee",
border_width = 0,
widget = {
widget = wibox.container.place,
qui.styled {
widget = wibox.container.background,
{
widget = wibox.container.margin,
margins = qvars.big_padding,
{
layout = wibox.layout.fixed.horizontal,
spacing = qvars.big_padding * 2,
id = "list",
},
},
},
},
}
local layout = powermenu._widget.widget:get_children_by_id("list")[1]
layout:add(create_button("Shutdown", phosphor.power_bold, qvars.colors.red, function()
awful.spawn "poweroff"
end))
layout:add(create_button("Log out", phosphor.sign_out_bold, qvars.colors.green, function()
awesome.quit()
end))
layout:add(create_button("Lock", phosphor.lock_simple_fill, qvars.colors.blue, function()
require("quarrel").debug "locked!l"
end))
layout:add(create_button("Restart", phosphor.arrow_clockwise_bold, qvars.colors.pink, function()
awful.spawn "reboot"
end))
end)
local timed = rubato.timed {
duration = qvars.anim_duration,
intro = qvars.anim_intro,
pos = 0,
subscribed = function(pos)
powermenu._widget.opacity = pos
if pos == 0 then
powermenu._widget.visible = false
else
powermenu._widget.visible = true
end
end,
}
function powermenu:toggle()
timed.target = toggled and 0 or 1
toggled = not toggled
end
return powermenu
|