Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
56b4d4d6
Commit
56b4d4d6
authored
Apr 23, 2013
by
Robby Russell
Browse files
Merge pull request #1738 from ronshapiro/master
Battery plugin changes
parents
d8d9da02
bc385531
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/battery/battery.plugin.zsh
View file @
56b4d4d6
...
@@ -10,12 +10,16 @@
...
@@ -10,12 +10,16 @@
if
[[
$(
uname
)
==
"Darwin"
]]
;
then
if
[[
$(
uname
)
==
"Darwin"
]]
;
then
function
battery_pct
()
{
typeset
-F
maxcapacity
=
$(
ioreg
-rc
"AppleSmartBattery"
|
grep
'^.*"MaxCapacity"\ =\ '
|
sed
-e
's/^.*"MaxCapacity"\ =\ //'
)
typeset
-F
currentcapacity
=
$(
ioreg
-rc
"AppleSmartBattery"
|
grep
'^.*"CurrentCapacity"\ =\ '
|
sed
-e
's/^.*CurrentCapacity"\ =\ //'
)
integer
i
=
$((
(
currentcapacity/maxcapacity
)
*
100
))
echo
$i
}
function
battery_pct_remaining
()
{
function
battery_pct_remaining
()
{
if
[[
$(
ioreg
-rc
AppleSmartBattery |
grep
-c
'^.*"ExternalConnected"\ =\ No'
)
-eq
1
]]
;
then
if
[[
$(
ioreg
-rc
AppleSmartBattery |
grep
-c
'^.*"ExternalConnected"\ =\ No'
)
-eq
1
]]
;
then
typeset
-F
maxcapacity
=
$(
ioreg
-rc
"AppleSmartBattery"
|
grep
'^.*"MaxCapacity"\ =\ '
|
sed
-e
's/^.*"MaxCapacity"\ =\ //'
)
battery_pct
typeset
-F
currentcapacity
=
$(
ioreg
-rc
"AppleSmartBattery"
|
grep
'^.*"CurrentCapacity"\ =\ '
|
sed
-e
's/^.*CurrentCapacity"\ =\ //'
)
integer
i
=
$((
(
currentcapacity/maxcapacity
)
*
100
))
echo
$i
else
else
echo
"External Power"
echo
"External Power"
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment