Skip to content

Commit

Permalink
removed osx from battery
Browse files Browse the repository at this point in the history
  • Loading branch information
napalm255 committed Dec 12, 2014
1 parent 1412da5 commit 2939054
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions plugins/battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ HEART_EMPTY="♡"

run_plugin() {
__process_settings
if shell_is_osx; then
battery_status=$(__battery_osx)
else
battery_status=$(__battery_linux)
fi
battery_status=$(__battery_linux)

[ -z "$battery_status" ] && return

case "$POWERTMUX_SEG_BATTERY_TYPE" in
Expand All @@ -36,40 +33,6 @@ __process_settings() {
fi
}

__battery_osx() {
ioreg -c AppleSmartBattery -w0 | \
grep -o '"[^"]*" = [^ ]*' | \
sed -e 's/= //g' -e 's/"//g' | \
sort | \
while read key value; do
case $key in
"MaxCapacity")
export maxcap=$value;;
"CurrentCapacity")
export curcap=$value;;
"ExternalConnected")
export extconnect=$value;;
"FullyCharged")
export fully_charged=$value;;
esac
if [[ -n $maxcap && -n $curcap && -n $extconnect ]]; then
if [[ "$curcap" == "$maxcap" || "$fully_charged" == "Yes" && $extconnect == "Yes" ]]; then
return
fi
charge=$(( 100 * $curcap / $maxcap ))
if [[ "$extconnect" == "Yes" ]]; then
echo "$charge"
else
if [[ $charge -lt 50 ]]; then
echo -n "#[fg=red]"
fi
echo "$charge"
fi
break
fi
done
}

__battery_linux() {
case "$SHELL_PLATFORM" in
"linux")
Expand Down

0 comments on commit 2939054

Please sign in to comment.