Support Multiple Batteries

Support Multiple Batteries

Out of the box the bar shows the combined charge of all batteries: in the X11 session once the i3xrocks-battery package is installed, and in the Wayland session by default. For some laptops that have multiple batteries, e.g. ThinkPads, you may want to have each battery displayed.

i3

  1. Install the battery blocklet if it is not installed yet:
sudo apt install i3xrocks-battery
  1. Stage your i3xrocks configuration files, including 80_battery, then open ~/.config/regolith3/i3xrocks/conf.d/80_battery in your editor of choice. Once ~/.config/regolith3/i3xrocks/conf.d contains files, the bar shows only the blocklets in that directory, so copy every blocklet you want to keep.
  2. Find the line that pertains to the battery blocklet:
~/.config/regolith3/i3xrocks/conf.d/80_battery
# Battery indicator
#
# Displays total percentage charge left of specified battery.
# You can specify the instance by adding:
# instance=BAT0
[battery]
interval=10
  1. List all the batteries on your machine by running:
upower --enumerate

# /org/freedesktop/UPower/devices/line_power_AC
# /org/freedesktop/UPower/devices/battery_BAT0
# /org/freedesktop/UPower/devices/battery_BAT1
# /org/freedesktop/UPower/devices/DisplayDevice
  1. Update the staged config file to have one blocklet per battery, using the UPower device names (battery_BAT0, battery_BAT1) as the instance:
~/.config/regolith3/i3xrocks/conf.d/80_battery
...
# Battery indicator
#
# Displays total percentage charge left of specified battery.
[battery]
interval=10
instance=battery_BAT0

[battery]
interval=10
instance=battery_BAT1
  1. Refresh the bar:
regolith-look refresh

Sway

  1. Stage your i3status-rust config file:
mkdir -p ~/.config/regolith3/i3status-rust
cp /etc/regolith/i3status-rust/config.toml ~/.config/regolith3/i3status-rust/config.toml
  1. Configure to supply i3status-rust with your config file:
echo "wm.bar.status_config: ~/.config/regolith3/i3status-rust/config.toml" >> ~/.config/regolith3/Xresources
  1. List all the battery instances running on your machine by running:
ls /sys/class/power_supply/

# AC BAT0 BAT1
  1. In the staged config file, replace the battery block (which shows the combined charge, device = "DisplayDevice") with one block per battery:
~/.config/regolith3/i3status-rust/config.toml
[[block]]
block = "battery"
interval = 10
device = "BAT0"

[[block]]
block = "battery"
interval = 10
device = "BAT1"
  1. Refresh the session, or log back in:
regolith-look refresh

See the i3status-rust battery block documentation for further options.

Further Reading

See the reference page for configurations for more details about config files in Regolith.

Last updated on