added battery support

This commit is contained in:
Ethan Edwards 2020-09-02 12:41:30 -04:00
parent 47fe175441
commit 3ccb5359ac

View file

@ -43,6 +43,10 @@ battery_percent()
echo $(pmset -g batt | grep -Eo '[0-9]?[0-9]?[0-9]%') echo $(pmset -g batt | grep -Eo '[0-9]?[0-9]?[0-9]%')
;; ;;
FreeBSD)
echo $(apm | sed '8,11d' | grep life | awk '{print $4}')
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*) CYGWIN*|MINGW32*|MSYS*|MINGW*)
# leaving empty - TODO - windows compatability # leaving empty - TODO - windows compatability
;; ;;
@ -64,6 +68,10 @@ battery_status()
status=$(pmset -g batt | sed -n 2p | cut -d ';' -f 2) status=$(pmset -g batt | sed -n 2p | cut -d ';' -f 2)
;; ;;
FreeBSD)
status=$(apm | sed '8,11d' | grep Status | awk '{printf $3}')
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*) CYGWIN*|MINGW32*|MSYS*|MINGW*)
# leaving empty - TODO - windows compatability # leaving empty - TODO - windows compatability
;; ;;
@ -72,11 +80,28 @@ battery_status()
;; ;;
esac esac
if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then case $status in
discharging|Discharging)
echo '' echo ''
else ;;
high)
echo ''
;;
charging)
echo 'AC' echo 'AC'
fi ;;
*)
echo 'AC'
;;
esac
### Old if statements didn't work on BSD, they're probably not POSIX compliant, not sure
# if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then
# echo ''
# # elif [ $status = 'charging' ]; then # This is needed for FreeBSD AC checking support
# # echo 'AC'
# else
# echo 'AC'
# fi
} }
main() main()