mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
Separate the battery_pct_remaining data into it's own function so that it can be obtained even if the battery is connected.
This commit is contained in:
parent
85426a57a2
commit
bc385531b0
1 changed files with 8 additions and 4 deletions
|
@ -10,12 +10,16 @@
|
||||||
|
|
||||||
if [[ $(uname) == "Darwin" ]] ; then
|
if [[ $(uname) == "Darwin" ]] ; then
|
||||||
|
|
||||||
function battery_pct_remaining() {
|
function battery_pct() {
|
||||||
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
|
||||||
typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
|
typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
|
||||||
typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
|
typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
|
||||||
integer i=$(((currentcapacity/maxcapacity) * 100))
|
integer i=$(((currentcapacity/maxcapacity) * 100))
|
||||||
echo $i
|
echo $i
|
||||||
|
}
|
||||||
|
|
||||||
|
function battery_pct_remaining() {
|
||||||
|
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
||||||
|
battery_pct
|
||||||
else
|
else
|
||||||
echo "External Power"
|
echo "External Power"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue