Merge pull request #997 from lfelipe1501/patch-1
Changes in the battery plugin and in the Atomic Themepull/1004/head
commit
4590042177
|
|
@ -10,6 +10,10 @@ ac_adapter_connected(){
|
||||||
then
|
then
|
||||||
acpi -a | grep -q "on-line"
|
acpi -a | grep -q "on-line"
|
||||||
return $?
|
return $?
|
||||||
|
elif command_exists pmset;
|
||||||
|
then
|
||||||
|
pmset -g batt | grep -q 'AC Power'
|
||||||
|
return $?
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
||||||
|
|
@ -30,6 +34,10 @@ ac_adapter_disconnected(){
|
||||||
then
|
then
|
||||||
acpi -a | grep -q "off-line"
|
acpi -a | grep -q "off-line"
|
||||||
return $?
|
return $?
|
||||||
|
elif command_exists pmset;
|
||||||
|
then
|
||||||
|
pmset -g batt | grep -q 'Battery Power'
|
||||||
|
return $?
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
||||||
|
|
@ -76,6 +84,17 @@ battery_percentage(){
|
||||||
echo '-1'
|
echo '-1'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
elif command_exists pmset;
|
||||||
|
then
|
||||||
|
local PMSET_OUTPUT=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p')
|
||||||
|
case $PMSET_OUTPUT in
|
||||||
|
100*)
|
||||||
|
echo '100'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $PMSET_OUTPUT | head -c 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
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: "?")}')
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,8 @@ ___atomic_prompt_battery() {
|
||||||
color=$IRed
|
color=$IRed
|
||||||
fi
|
fi
|
||||||
box="[|]"
|
box="[|]"
|
||||||
ac_adapter_disconnected && info="-"
|
|
||||||
ac_adapter_connected && info="+"
|
ac_adapter_connected && info="+"
|
||||||
|
ac_adapter_disconnected && info="-"
|
||||||
info+=$batp
|
info+=$batp
|
||||||
[ "$batp" -eq 100 ] || [ "$batp" -gt 100 ] && info="AC"
|
[ "$batp" -eq 100 ] || [ "$batp" -gt 100 ] && info="AC"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue