Skip to content

Instantly share code, notes, and snippets.

@larsbratholm
Created September 24, 2016 14:49
Show Gist options
  • Save larsbratholm/ef3a1e5082ff95147f22dc6037d4537e to your computer and use it in GitHub Desktop.
Save larsbratholm/ef3a1e5082ff95147f22dc6037d4537e to your computer and use it in GitHub Desktop.
Charge monitoring for dual batteries in e.g. i3 status bar
# i3status configuration file.
order += "battery 2"
battery 2 {
integer_battery_capacity = true
last_full_capacity = true
path = "/home/lab/.uevent"
format = "%status %percentage %remaining"
}
#!/bin/bash
while true
do
paste /sys/class/power_supply/BAT0/uevent /sys/class/power_supply/BAT1/uevent | awk '{split($0,a,"="); split(a[2],b," "); (a[3] == "Charging" || b[1] == "Charging") ? $5 = "Charging" : $5 = (a[3] + b[1])/2; print a[1] "=" $5}' > /home/lab/.uevent
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment