A simple script to display the battery percentage and status (charging, discharging, or low battery) in your i3blocks status bar. Supports systems with one or two batteries.
- Interactive button allowing user to check the remaining battery time by left-clicking.
- Displays the combined battery percentage for systems with multiple batteries.
- Shows charging status with an icon (
β‘
). - Alerts for low battery levels with an icon (
π
). - Works seamlessly with i3blocks on Arch Linux or any Linux distribution using
i3wm
.
- Linux system with
i3wm
andi3blocks
installed. - Battery information available under
/sys/class/power_supply/BAT0
and/sys/class/power_supply/BAT1
(or onlyBAT0
for single-battery systems).
git clone https://github.com/dawidadamowicz/i3blocks-dual-battery-status.git
cd i3blocks-dual-battery-status
Copy the battery_status.sh
script to your i3blocks configuration directory:
mkdir -p ~/.config/i3blocks
cp battery_status.sh ~/.config/i3blocks/
chmod +x ~/.config/i3blocks/battery_status.sh
Add the following block to your i3blocks configuration file (usually located at ~/.config/i3blocks/config
):
[battery]
command=~/.config/i3blocks/battery_status.sh
interval=30
Reload i3blocks to apply the changes:
pkill -SIGRTMIN+10 i3blocks
- The script checks the battery status and capacity for
/sys/class/power_supply/BAT0
and/sys/class/power_supply/BAT1
. - If multiple batteries are present, it calculates the average percentage.
- Icons are displayed based on the status:
β‘
for charging.π
for low battery (β€20%).
- Outputs the battery percentage and icon in the i3blocks bar.
Status | Output |
---|---|
Charging | β‘ 65% |
Low Battery | π 18% |
Discharging | 54% |
No Battery Found | No battery |