A widget to display the current battery and power supply status in awesome wm using upower, which is used by most desktop environments. This is very efficient as it uses dbus signals from upower instead of polling. The configuration is similiar to the well-known lain widgets and can be used as a drop-in replacement (in most cases) for the lain battery widget. Works flawless with multiple batteries.
AwesomeWM-4.0 with dbus support enabled
Clone the repo into your $XDG_CONFIG_HOME/awesome
directory and add the
dependency to your rc.lua
.
cd "$XDG_CONFIG_HOME/awesome"
git clone https://github.com/berlam/awesome-upower-battery.git awesome-upower-battery
local battery = require("awesome-upower-battery")
You can customize the apperance inside your rc.lua
. This widgets exposes some fields.
settings
can use the bat_now
table, which contains the following strings:
status
, battery status ("N/A", "Discharging", "Charging", "Full");ac_status
, AC-plug flag (0 if cable is unplugged, 1 if plugged, "N/A" otherwise);perc
, total charge percentage (integer between 0 and 100 or "N/A");time
, time remaining until charge if charging, until discharge if discharging (HH:SS string or "N/A");watt
, battery watts.
Configure the widget with the settings property.
local bat = battery(
{
settings = function(bat_now, widget)
if bat_now.status == "Discharging" then
widget:set_markup(string.format("%3d", bat_now.perc) .. "% ")
return
end
-- We must be on AC
baticon:set_image(beautiful.ac)
widget:set_markup(bat_now.time .. " ")
end
}
)
Add the bat.widget
to your wibar.
This plugin was created by Matthias Berla.
See LICENSE.