Commit ae1973de authored by Ron Shapiro's avatar Ron Shapiro
Browse files

plugged_in function

parent bc385531
...@@ -16,12 +16,16 @@ if [[ $(uname) == "Darwin" ]] ; then ...@@ -16,12 +16,16 @@ if [[ $(uname) == "Darwin" ]] ; then
integer i=$(((currentcapacity/maxcapacity) * 100)) integer i=$(((currentcapacity/maxcapacity) * 100))
echo $i echo $i
} }
function plugged_in() {
[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ]
}
function battery_pct_remaining() { function battery_pct_remaining() {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then if plugged_in ; then
battery_pct
else
echo "External Power" echo "External Power"
else
battery_pct
fi fi
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment