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
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 '