Created
October 22, 2017 04:41
-
-
Save JGrossholtz/87975101e86d9e6f39f13c3b965f6aa3 to your computer and use it in GitHub Desktop.
Script that calculates average battery percentage for a laptop with 2 batteries
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/sh | |
# This script can be used to determine the average load of 2 batteries | |
# It requires the acpi command. | |
battA=$(acpi | grep "Battery \0" | cut -d" " -f 4 | sed "s/[^0-9]//g") | |
battB=$(acpi | grep "Battery 1" | cut -d" " -f 4 | sed "s/[^0-9]//g") | |
avg=$((($battA+$battB)/2)) | |
if [ "$(acpi | grep "Discharging" | wc -l)" = 0 ]; then | |
echo [$avg%] | |
else | |
echo -e "$avg%" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment