Merge pull request #168 from dawidd6/battery_status
added battery status for linux and freebsd (only one battery)
This commit is contained in:
commit
f5ec035e18
20
neofetch
20
neofetch
|
@ -1556,7 +1556,8 @@ getbattery () {
|
||||||
|
|
||||||
# Create an array of battery usage from each battery.
|
# 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))
|
||||||
# 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,7 +1585,11 @@ getbattery () {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
battery="${batteries[0]}%"
|
if [ "$battery_status" == "Charging" ]; then
|
||||||
|
battery="${batteries[0]}% Charging"
|
||||||
|
else
|
||||||
|
battery="${batteries[0]}%"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
battery="None"
|
battery="None"
|
||||||
|
@ -1594,7 +1599,13 @@ getbattery () {
|
||||||
"BSD")
|
"BSD")
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"FreeBSD"*)
|
"FreeBSD"*)
|
||||||
battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')
|
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}')
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"NetBSD"*)
|
"NetBSD"*)
|
||||||
|
@ -1616,6 +1627,9 @@ 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" == "charging;" ] && \
|
||||||
|
battery="${battery} Charging"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Windows")
|
"Windows")
|
||||||
|
|
Reference in New Issue