Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

plugged_in function #1776

Merged
merged 1 commit into from

2 participants

Ron Shapiro Robby Russell
Ron Shapiro

No description provided.

Robby Russell robbyrussell merged commit e8b85f9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 29, 2013
  1. Ron Shapiro

    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
10 plugins/battery/battery.plugin.zsh
View
@@ -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.