Added AC indicator support on OS X

Not sure about the logic for returning 1/0 from the function, though -
will have to clarify.
pull/702/head
Nils Winkler 2016-04-12 09:54:03 +02:00
parent 5035b2d815
commit a9c5670c2c
2 changed files with 17 additions and 9 deletions

View File

@ -2,15 +2,23 @@ cite about-plugin
about-plugin 'display info about your battery charge level' about-plugin 'display info about your battery charge level'
ac_adapter_connected(){ ac_adapter_connected(){
if command_exists acpi; if command_exists acpi;
then then
acpi -a | grep "on-line" acpi -a | grep "on-line"
if [[ "$?" -eq 0 ]]; then if [[ "$?" -eq 0 ]]; then
return 1 return 1
else else
return 0 return 0
fi
fi fi
elif command_exists ioreg;
then
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | grep '"ExternalConnected"' | awk -F'=' '{print $2}')
if [[ "$IOREG_OUTPUT" == *"Yes"* ]]; then
return 0
else
return 1
fi
fi
} }
battery_percentage(){ battery_percentage(){

View File

@ -153,7 +153,7 @@ function __powerline_battery_prompt {
else else
color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"
fi fi
[[ "$(ac_adapter_connected)" ]] && battery_status="${BATTERY_AC_CHAR}${battery_status}" ac_adapter_connected && battery_status="${BATTERY_AC_CHAR} ${battery_status}"
echo "${battery_status}%|${color}" echo "${battery_status}%|${color}"
fi fi
} }