commit
07b9305d2f
|
|
@ -10,6 +10,10 @@ ac_adapter_connected(){
|
|||
then
|
||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
||||
return $?
|
||||
elif command_exists WMIC;
|
||||
then
|
||||
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2'
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -22,6 +26,10 @@ ac_adapter_disconnected(){
|
|||
then
|
||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
||||
return $?
|
||||
elif command_exists WMIC;
|
||||
then
|
||||
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1'
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -58,9 +66,6 @@ battery_percentage(){
|
|||
esac
|
||||
elif command_exists ioreg;
|
||||
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: "?")}')
|
||||
case $IOREG_OUTPUT in
|
||||
100*)
|
||||
|
|
@ -70,6 +75,17 @@ battery_percentage(){
|
|||
echo $IOREG_OUTPUT | head -c 2
|
||||
;;
|
||||
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
|
||||
echo "no"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -9,12 +9,9 @@
|
|||
IRed="\e[1;49;31m"
|
||||
IGreen="\e[1;49;32m"
|
||||
IYellow="\e[1;49;33m"
|
||||
ICyan="\e[1;49;36m"
|
||||
IWhite="\e[1;49;37m"
|
||||
White="\e[0;49;37m"
|
||||
BIWhite="\e[1;49;37m"
|
||||
BICyan="\e[1;49;36m"
|
||||
ResetColor="\e[0;49;37m"
|
||||
|
||||
#############
|
||||
## Symbols ##
|
||||
|
|
@ -167,14 +164,14 @@ ___atomic_prompt_clock() {
|
|||
}
|
||||
|
||||
___atomic_prompt_battery() {
|
||||
[ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
|
||||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
||||
chk=$(command_exists battery_percentage && echo yes || echo no)
|
||||
[ "$chk" != "yes" ] || [ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
||||
batp=$(battery_percentage)
|
||||
if [ "$batp" -gt 50 ]; then
|
||||
if [ "$batp" -eq 50 ] || [ "$batp" -gt 50 ]; then
|
||||
color=$bold_green
|
||||
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
||||
color=$bold_yellow
|
||||
elif [ "$batp" -lt 25 ]; then
|
||||
elif [ "$batp" -eq 25 ] || [ "$batp" -lt 25 ]; then
|
||||
color=$IRed
|
||||
fi
|
||||
box="[|]"
|
||||
|
|
|
|||
Loading…
Reference in New Issue