Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

plugged_in function #1776

Merged
merged 1 commit into from

2 participants

@ronshapiro

No description provided.

@robbyrussell robbyrussell merged commit e8b85f9 into robbyrussell:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 29, 2013
  1. @ronshapiro

    plugged_in function

    ronshapiro authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 3 deletions.
  1. +7 −3 plugins/battery/battery.plugin.zsh
View
10 plugins/battery/battery.plugin.zsh
@@ -16,12 +16,16 @@ if [[ $(uname) == "Darwin" ]] ; then
integer i=$(((currentcapacity/maxcapacity) * 100))
echo $i
}
+
+ function plugged_in() {
+ [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ]
+ }
function battery_pct_remaining() {
- if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
- battery_pct
- else
+ if plugged_in ; then
echo "External Power"
+ else
+ battery_pct
fi
}
Something went wrong with that request. Please try again.