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
|
local qmath = require "quarrel.math"
local qvars = require "quarrel.vars"
local wibox = require "wibox"
local battery_bar = wibox.widget {
widget = wibox.container.place,
forced_height = qvars.char_height,
{
{
widget = wibox.container.constraint,
width = qvars.char_width * 4,
strategy = "exact",
{
widget = wibox.widget.textbox,
text = "0%"
},
id = "text"
},
nil,
{
widget = wibox.container.margin,
margins = {
left = qvars.padding
},
{
widget = wibox.container.place,
{
widget = wibox.widget.progressbar,
max_value = 100,
value = 0,
forced_height = qvars.char_height / 4,
shape = qvars.shape,
background_color = qvars.colors.black,
color = qvars.colors.red,
}
},
id = "bar"
},
layout = wibox.layout.align.horizontal,
-- expand = "outside"
}
}
awesome.connect_signal("services::battery", function(capacity)
local color = qmath.step_value(capacity, {
{ 0, "red" },
{ 20, "red" },
{ 40, "yellow" },
{ 60, "green" },
{ 80, "green" },
{ 100 }
})
battery_bar.widget.bar.widget.widget.color = qvars.colors[color]
battery_bar.widget.bar.widget.widget.value = capacity
battery_bar.widget.text.widget.text = capacity .. "%"
end)
return battery_bar
|