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
5d8e1f82
Unverified
Commit
5d8e1f82
authored
Nov 11, 2020
by
aimuz
Committed by
GitHub
Nov 10, 2020
Browse files
fix(battery): use `pmset` for battery percentage in macOS (#9364)
Returns the battery charge consistent with the system battery manager
parent
eef04c62
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/battery/battery.plugin.zsh
View file @
5d8e1f82
...
@@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
...
@@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
}
function
battery_pct
()
{
function
battery_pct
()
{
local
battery_status
=
"
$(
ioreg
-rc
AppleSmartBattery
)
"
pmset
-g
batt |
grep
-Eo
"
\d
+%"
|
cut
-d
%
-f1
local
-i
capacity
=
$(
sed
-n
-e
'/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p'
<<<
$battery_status
)
local
-i
current
=
$(
sed
-n
-e
'/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p'
<<<
$battery_status
)
echo
$((
current
*
100
/
capacity
))
}
}
function
battery_pct_remaining
()
{
function
battery_pct_remaining
()
{
...
...
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