Fix Linux implementation of battery.sh

This commit is contained in:
Nicholas Young 2020-05-21 13:36:59 -06:00 committed by GitHub
parent ce678ab116
commit 63a53b07bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,13 +1,11 @@
#!/usr/bin/env bash
BAT=$(ls /sys/class/power_supply/BAT* | head -1)
battery_percent()
{
# Check OS
case $(uname -s) in
Linux)
cat $BAT/capacity
cat /sys/class/power_supply/BAT0/capacity
;;
Darwin)
@ -28,7 +26,7 @@ battery_status()
# Check OS
case $(uname -s) in
Linux)
status=$(cat $BAT/status)
status=$(cat /sys/class/power_supply/BAT0/status)
;;
Darwin)
@ -43,7 +41,7 @@ battery_status()
;;
esac
if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then
if [[ $status = 'discharging' ]] || [[ $status = 'Discharging' ]]; then
echo ''
else
echo 'AC '