105 lines
4 KiB
Lua
105 lines
4 KiB
Lua
local qmath = require "quarrel.math"
|
|
local qvars = require "quarrel.vars"
|
|
local qui = require "quarrel.ui"
|
|
local wibox = require "wibox"
|
|
local phosphor = require "assets.phosphor"
|
|
local gcolor = require "gears.color"
|
|
|
|
local function create_display(icon, color)
|
|
return wibox.widget(qui.styled {
|
|
widget = wibox.container.background,
|
|
{
|
|
widget = wibox.container.margin,
|
|
margins = qvars.big_padding,
|
|
{
|
|
widget = wibox.container.place,
|
|
{
|
|
{
|
|
widget = wibox.container.radialprogressbar,
|
|
max_value = 100,
|
|
border_color = qvars.colors.black,
|
|
color = color,
|
|
border_width = qvars.border_width * 2,
|
|
forced_height = qvars.element_size * 4,
|
|
forced_width = qvars.element_size * 4,
|
|
{
|
|
widget = wibox.container.place,
|
|
{
|
|
widget = wibox.widget.imagebox,
|
|
image = icon,
|
|
forced_height = qvars.char_height,
|
|
forced_width = qvars.char_height,
|
|
id = "icon"
|
|
}
|
|
},
|
|
id = "indicator"
|
|
},
|
|
{
|
|
widget = wibox.container.place,
|
|
{
|
|
widget = wibox.widget.textbox,
|
|
text = "0%",
|
|
id = "text"
|
|
}
|
|
},
|
|
layout = wibox.layout.fixed.vertical,
|
|
spacing = qvars.big_padding
|
|
}
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
local d_battery = create_display(gcolor.recolor_image(phosphor.battery_vertical_warning_fill, qvars.colors.fg), qvars.colors.red)
|
|
|
|
awesome.connect_signal("services::battery", function(capacity, status)
|
|
local icon_data = status == "Charging" and { "charging", "green" } or qmath.step_value(capacity, {
|
|
{ 0, { "empty", "red" } },
|
|
{ 20, { "low", "red" } },
|
|
{ 40, { "medium", "yellow" } },
|
|
{ 60, { "high", "green" } },
|
|
{ 80, { "full", "green" } },
|
|
{ 100 }
|
|
})
|
|
|
|
d_battery:get_children_by_id("indicator")[1].color = qvars.colors[icon_data[2]]
|
|
d_battery:get_children_by_id("indicator")[1].value = capacity
|
|
d_battery:get_children_by_id("icon")[1].image = gcolor.recolor_image(phosphor["battery_vertical_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]])
|
|
|
|
d_battery:get_children_by_id("text")[1].text = capacity .. "%"
|
|
end)
|
|
|
|
local d_volume = create_display(gcolor.recolor_image(phosphor.speaker_simple_high_fill, qvars.colors.fg), qvars.colors.fg)
|
|
|
|
awesome.connect_signal("services::audio", function(volume, muted)
|
|
d_volume:get_children_by_id("indicator")[1].value = math.min(volume, 100)
|
|
d_volume:get_children_by_id("text")[1].text = volume .. "%"
|
|
|
|
if muted then
|
|
d_volume:get_children_by_id("icon")[1].image = gcolor.recolor_image(phosphor["speaker_simple_x_fill"], qvars.colors.red)
|
|
return
|
|
end
|
|
|
|
local icon_data = qmath.step_value(volume, {
|
|
{ 0, "slash" },
|
|
{ 25, "none" },
|
|
{ 50, "low" },
|
|
{ 75, "high" },
|
|
{ 100 }
|
|
})
|
|
|
|
d_volume:get_children_by_id("icon")[1].image = gcolor.recolor_image(phosphor["speaker_simple_" .. icon_data .. "_fill"], qvars.colors.fg)
|
|
end)
|
|
|
|
local d_brightness = create_display(gcolor.recolor_image(phosphor.sun_fill, qvars.colors.fg), qvars.colors.fg)
|
|
|
|
awesome.connect_signal("services::brightness", 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)
|
|
|
|
return { battery = d_battery, volume = d_volume, brightness = d_brightness }
|