Merge pull request #26 from secretfader/master
Fix Linux implementation of battery.sh
This commit is contained in:
commit
fb47f11a57
1 changed files with 3 additions and 5 deletions
|
@ -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 '
|
||||||
|
|
Loading…
Reference in a new issue