Merge pull request #26 from secretfader/master

Fix Linux implementation of battery.sh
This commit is contained in:
Dane Williams 2020-05-21 13:07:25 -07:00 committed by GitHub
commit fb47f11a57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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