This repository has been archived on 2021-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/home/.config/awesome/battery.lua

33 lines
756 B
Lua

local timer = require("gears.timer")
local wibox = require("wibox")
local utils = require("utils")
local battery_widget = wibox.widget{
markup = 'U00',
align = 'center',
widget = wibox.widget.textbox
}
timer = timer({ timeout = 10 })
timer:connect_signal("timeout", function() update() end)
timer:start()
function update()
local percent = utils.readfile("/sys/class/power_supply/BAT1/capacity")
local status = utils.readfile("/sys/class/power_supply/BAT1/status")
if status == "Charging" then
prefix = "C"
elseif status == "Discharging" then
prefix = "D"
else
prefix = "F"
end
battery_widget:set_markup(prefix .. percent)
end
update()
return wibox.container.margin(battery_widget, 4)