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
|
-- local backlight = require "services.backlight"
local battery = require "services.battery"
local phosphor = require "assets.phosphor"
-- local qmath = require "quarrel.math"
local C = require "ui.statusbar.consts"
local qcolor = require "quarrel.color"
local qui = require "quarrel.ui"
local wibox = require "wibox"
local function create_display(icon, color)
-- the reason this is done is because ids can't be found with `get_children_by_id` across widget boundaries,
-- so we return it as a second value in order to manipulate the icon
local d_icon = qui.icon {
icon = icon,
color = color,
widget = {
id = "icon",
},
}
return wibox.widget(qui.styled {
widget = wibox.container.background,
bg = qcolor.palette.bg.high,
{
widget = wibox.container.margin,
margins = qui.BIG_PADDING,
{
widget = wibox.container.place,
{
{
widget = wibox.container.radialprogressbar,
max_value = 100,
border_color = qcolor.palette.bg.lowest,
color = color,
border_width = qui.BORDER_WIDTH * 2,
forced_height = C.ELEMENT_SIZE * 4,
forced_width = C.ELEMENT_SIZE * 4,
{
widget = wibox.container.place,
d_icon,
},
id = "indicator",
},
{
widget = wibox.container.place,
{
widget = wibox.widget.textbox,
text = "0%",
id = "text",
},
},
layout = wibox.layout.fixed.vertical,
spacing = qui.BIG_PADDING,
},
},
},
}),
d_icon
end
local d_audio, d_audio_icon = create_display(phosphor.speaker_simple_high_fill, qcolor.palette.fg())
awesome.connect_signal("services::audio", function(volume)
if not volume then
return
end
d_audio:get_children_by_id("indicator")[1].value = math.min(volume, 100)
d_audio:get_children_by_id("text")[1].text = volume .. "%"
end)
awesome.connect_signal("services::audio::icon", function(icon, color)
d_audio:get_children_by_id("indicator")[1].color = color
d_audio_icon.image = icon
d_audio_icon.stylesheet = qui.recolor(color)
end)
local d_battery, d_battery_icon = create_display(phosphor.battery_vertical_warning_fill, qcolor.palette.red())
battery:connect_signal("level", function(_, level)
d_battery:get_children_by_id("indicator")[1].value = level
d_battery:get_children_by_id("text")[1].text = level .. "%"
end)
battery:connect_signal("icon", function(_, icon, color)
d_battery:get_children_by_id("indicator")[1].color = color
d_battery_icon.image = icon
d_battery_icon.stylesheet = qui.recolor(color)
end)
-- local d_brightness, d_brightness_icon = create_display(phosphor.sun_fill, qcolor.palette.fg())
-- backlight:connect_signal("value", function(_, brightness)
-- brightness = math.floor(qmath.translate_range(brightness, 0, 255, 0, 100))
-- d_brightness:get_children_by_id("indicator")[1].value = brightness
-- d_brightness:get_children_by_id("text")[1].text = brightness .. "%"
-- end)
-- backlight:connect_signal("icon", function(_, icon, color)
-- d_brightness_icon.image = icon
-- d_brightness_icon.stylesheet = qui.recolor(color)
-- end)
return {
audio = d_audio,
battery = d_battery, --[[brightness = d_brightness]]
}
|