Merge branch 'battery_status' of https://github.com/dawidd6/neofetch into battery_status_mac

This commit is contained in:
Andrew Titmuss 2016-03-21 12:10:23 +11:00
commit 2146f6d214
1 changed files with 13 additions and 3 deletions

View File

@ -1551,7 +1551,8 @@ getbattery () {
# Create an array of battery usage from each battery.
batteries=($(cat /sys/class/power_supply/BAT${battery_num}/capacity))
# Get the power status
power_status=($(cat /sys/class/power_supply/BAT${battery_num}/status))
# Get the subtitle and reassign it so it doesn't change.
title="$subtitle"
@ -1578,8 +1579,11 @@ getbattery () {
done
return
fi
battery="${batteries[0]}%"
if [ $power_status = "Charging" ]; then
battery="${batteries[0]}% ${power_status}"
else
battery="${batteries[0]}%"
fi
fi
else
battery="None"
@ -1589,7 +1593,13 @@ getbattery () {
"BSD")
case "$distro" in
"FreeBSD"*)
power_status=$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}')
if [ $power_status = "charging" ]; then
battery="$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}') $power_status"
else
battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')
fi
;;
"NetBSD"*)