Simplified logic for both Linux and OS X
Avoiding the if statements, using exit code of `grep -q` instead. Reverted the change that adds a space after the AC char. Opting for a default value, allowing to override from one's profile.pull/702/head
parent
a9c5670c2c
commit
e5d50f0d97
|
|
@ -4,20 +4,12 @@ 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 -q "on-line"
|
||||||
if [[ "$?" -eq 0 ]]; then
|
return $?
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | grep '"ExternalConnected"' | awk -F'=' '{print $2}')
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
||||||
if [[ "$IOREG_OUTPUT" == *"Yes"* ]]; then
|
return $?
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ LAST_STATUS_THEME_PROMPT_COLOR=196
|
||||||
|
|
||||||
CLOCK_THEME_PROMPT_COLOR=240
|
CLOCK_THEME_PROMPT_COLOR=240
|
||||||
|
|
||||||
BATTERY_AC_CHAR="⚡"
|
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
|
||||||
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
|
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
|
||||||
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
|
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
|
||||||
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
|
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue