Created
September 24, 2016 14:49
-
-
Save larsbratholm/ef3a1e5082ff95147f22dc6037d4537e to your computer and use it in GitHub Desktop.
Charge monitoring for dual batteries in e.g. i3 status bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# i3status configuration file. | |
order += "battery 2" | |
battery 2 { | |
integer_battery_capacity = true | |
last_full_capacity = true | |
path = "/home/lab/.uevent" | |
format = "%status %percentage %remaining" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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