Merge pull request #176 from dylanaraps/battery_fixes
Remove duplicate blocks from the battery function.
This commit is contained in:
commit
5eaa3cba79
1 changed files with 8 additions and 17 deletions
21
neofetch
21
neofetch
|
@ -1554,10 +1554,9 @@ getbattery () {
|
||||||
*) index="$battery_num" ;;
|
*) index="$battery_num" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create an array of battery usage from each battery.
|
|
||||||
batteries=($(cat /sys/class/power_supply/BAT${battery_num}/capacity))
|
batteries=($(cat /sys/class/power_supply/BAT${battery_num}/capacity))
|
||||||
# Get the power status
|
|
||||||
battery_status=($(cat /sys/class/power_supply/BAT${battery_num}/status))
|
battery_status=($(cat /sys/class/power_supply/BAT${battery_num}/status))
|
||||||
|
|
||||||
# Get the subtitle and reassign it so it doesn't change.
|
# Get the subtitle and reassign it so it doesn't change.
|
||||||
title="$subtitle"
|
title="$subtitle"
|
||||||
|
|
||||||
|
@ -1584,13 +1583,8 @@ getbattery () {
|
||||||
done
|
done
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$battery_status" == "Charging" ]; then
|
|
||||||
battery="${batteries[0]}% Charging"
|
|
||||||
else
|
|
||||||
battery="${batteries[0]}%"
|
battery="${batteries[0]}%"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
battery="None"
|
battery="None"
|
||||||
fi
|
fi
|
||||||
|
@ -1599,13 +1593,8 @@ getbattery () {
|
||||||
"BSD")
|
"BSD")
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"FreeBSD"*)
|
"FreeBSD"*)
|
||||||
battery_status=$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}')
|
|
||||||
|
|
||||||
if [ "$battery_status" == "charging" ]; then
|
|
||||||
battery="$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}') Charging"
|
|
||||||
else
|
|
||||||
battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')
|
battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')
|
||||||
fi
|
battery_status=$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}')
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"NetBSD"*)
|
"NetBSD"*)
|
||||||
|
@ -1628,8 +1617,6 @@ getbattery () {
|
||||||
"Mac OS X")
|
"Mac OS X")
|
||||||
battery="$(pmset -g batt | grep -o '[0-9]*%')"
|
battery="$(pmset -g batt | grep -o '[0-9]*%')"
|
||||||
battery_status="$(pmset -g batt | awk 'NR==2 {print $3}')"
|
battery_status="$(pmset -g batt | awk 'NR==2 {print $3}')"
|
||||||
[ "$battery_status" == "charging;" ] && \
|
|
||||||
battery="${battery} Charging"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Windows")
|
"Windows")
|
||||||
|
@ -1641,6 +1628,10 @@ getbattery () {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
case "$battery_status" in
|
||||||
|
*"charging"*) battery+=" Charging" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
case "$battery_display" in
|
case "$battery_display" in
|
||||||
"bar") battery="$(bar ${battery/'%'} 100)" ;;
|
"bar") battery="$(bar ${battery/'%'} 100)" ;;
|
||||||
"infobar") battery="${battery} $(bar "${battery/'%'}" 100)" ;;
|
"infobar") battery="${battery} $(bar "${battery/'%'}" 100)" ;;
|
||||||
|
|
Loading…
Reference in a new issue