commit
07b9305d2f
|
|
@ -10,6 +10,10 @@ ac_adapter_connected(){
|
||||||
then
|
then
|
||||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
||||||
return $?
|
return $?
|
||||||
|
elif command_exists WMIC;
|
||||||
|
then
|
||||||
|
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2'
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,6 +26,10 @@ ac_adapter_disconnected(){
|
||||||
then
|
then
|
||||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
||||||
return $?
|
return $?
|
||||||
|
elif command_exists WMIC;
|
||||||
|
then
|
||||||
|
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1'
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,9 +66,6 @@ battery_percentage(){
|
||||||
esac
|
esac
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
# http://hints.macworld.com/article.php?story=20100130123935998
|
|
||||||
#local IOREG_OUTPUT_10_6=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}')
|
|
||||||
#local IOREG_OUTPUT_10_5=$(ioreg -l | grep -i capacity | grep -v Legacy| tr '\n' ' | ' | awk '{printf("%.2f%%", $14/$7 * 100)}')
|
|
||||||
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
|
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
|
||||||
case $IOREG_OUTPUT in
|
case $IOREG_OUTPUT in
|
||||||
100*)
|
100*)
|
||||||
|
|
@ -70,6 +75,17 @@ battery_percentage(){
|
||||||
echo $IOREG_OUTPUT | head -c 2
|
echo $IOREG_OUTPUT | head -c 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
elif command_exists WMIC;
|
||||||
|
then
|
||||||
|
local WINPC=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*')
|
||||||
|
case $WINPC in
|
||||||
|
100*)
|
||||||
|
echo '100'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $WINPC
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
echo "no"
|
echo "no"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,9 @@
|
||||||
IRed="\e[1;49;31m"
|
IRed="\e[1;49;31m"
|
||||||
IGreen="\e[1;49;32m"
|
IGreen="\e[1;49;32m"
|
||||||
IYellow="\e[1;49;33m"
|
IYellow="\e[1;49;33m"
|
||||||
ICyan="\e[1;49;36m"
|
|
||||||
IWhite="\e[1;49;37m"
|
IWhite="\e[1;49;37m"
|
||||||
White="\e[0;49;37m"
|
|
||||||
BIWhite="\e[1;49;37m"
|
BIWhite="\e[1;49;37m"
|
||||||
BICyan="\e[1;49;36m"
|
BICyan="\e[1;49;36m"
|
||||||
ResetColor="\e[0;49;37m"
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
## Symbols ##
|
## Symbols ##
|
||||||
|
|
@ -167,14 +164,14 @@ ___atomic_prompt_clock() {
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_battery() {
|
___atomic_prompt_battery() {
|
||||||
[ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
|
chk=$(command_exists battery_percentage && echo yes || echo no)
|
||||||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
[ "$chk" != "yes" ] || [ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
||||||
batp=$(battery_percentage)
|
batp=$(battery_percentage)
|
||||||
if [ "$batp" -gt 50 ]; then
|
if [ "$batp" -eq 50 ] || [ "$batp" -gt 50 ]; then
|
||||||
color=$bold_green
|
color=$bold_green
|
||||||
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
||||||
color=$bold_yellow
|
color=$bold_yellow
|
||||||
elif [ "$batp" -lt 25 ]; then
|
elif [ "$batp" -eq 25 ] || [ "$batp" -lt 25 ]; then
|
||||||
color=$IRed
|
color=$IRed
|
||||||
fi
|
fi
|
||||||
box="[|]"
|
box="[|]"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue