2023-04-04 08:43:40 -05:00
|
|
|
local gcolor = require "gears.color"
|
|
|
|
local phosphor = require "assets.phosphor"
|
2023-04-11 17:44:52 -05:00
|
|
|
local qmath = require "quarrel.math"
|
|
|
|
local qvars = require "quarrel.vars"
|
|
|
|
local wibox = require "wibox"
|
2023-01-29 02:59:52 -06:00
|
|
|
|
2023-04-04 08:43:40 -05:00
|
|
|
local battery = wibox.widget {
|
|
|
|
widget = wibox.container.place,
|
|
|
|
valign = "center",
|
|
|
|
halign = "center",
|
|
|
|
{
|
|
|
|
widget = wibox.widget.imagebox,
|
2023-05-12 09:18:24 -05:00
|
|
|
image = gcolor.recolor_image(phosphor.battery_vertical_warning_fill, qvars.colors.red),
|
|
|
|
forced_width = qvars.char_height,
|
|
|
|
forced_height = qvars.char_height
|
2023-04-04 08:43:40 -05:00
|
|
|
}
|
|
|
|
}
|
2023-01-29 02:59:52 -06:00
|
|
|
|
2023-04-04 08:43:40 -05:00
|
|
|
awesome.connect_signal("services::battery", function(capacity, status)
|
2023-05-12 09:18:24 -05:00
|
|
|
local icon_data = status == "Charging" and { "charging", "green" } or qmath.step_value(capacity, {
|
2023-04-04 08:43:40 -05:00
|
|
|
{ 0, { "empty", "red" } },
|
|
|
|
{ 20, { "low", "red" } },
|
|
|
|
{ 40, { "medium", "yellow" } },
|
|
|
|
{ 60, { "high", "green" } },
|
|
|
|
{ 80, { "full", "green" } },
|
|
|
|
{ 100 }
|
|
|
|
})
|
2023-01-29 02:59:52 -06:00
|
|
|
|
2023-04-04 08:43:40 -05:00
|
|
|
battery.widget.image = gcolor.recolor_image(phosphor["battery_vertical_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]])
|
2023-03-04 15:04:55 -06:00
|
|
|
end)
|
2023-01-29 02:59:52 -06:00
|
|
|
|
|
|
|
return battery
|