Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
9aeb9675
Unverified
Commit
9aeb9675
authored
Oct 08, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(battery): fix system check so Termux uses the correct method
parent
f26a1ecd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
battery.plugin.zsh
plugins/battery/battery.plugin.zsh
+40
-40
No files found.
plugins/battery/battery.plugin.zsh
View file @
9aeb9675
...
@@ -99,6 +99,46 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
...
@@ -99,6 +99,46 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo
"%{
$fg
[
$color
]%}
${
battery_pct
}
%%%{
$reset_color
%}"
echo
"%{
$fg
[
$color
]%}
${
battery_pct
}
%%%{
$reset_color
%}"
fi
fi
}
}
elif
[[
"
$OSTYPE
"
=
linux-android
]]
&&
((
${
+commands[termux-battery-status]
}
))
;
then
function
battery_is_charging
()
{
termux-battery-status 2>/dev/null |
command awk
'/status/ { exit ($0 ~ /DISCHARGING/) }'
}
function
battery_pct
()
{
# Sample output:
# {
# "health": "GOOD",
# "percentage": 93,
# "plugged": "UNPLUGGED",
# "status": "DISCHARGING",
# "temperature": 29.0,
# "current": 361816
# }
termux-battery-status 2>/dev/null |
command awk
'/percentage/ { gsub(/[,]/,""); print $2}'
}
function
battery_pct_remaining
()
{
if
!
battery_is_charging
;
then
battery_pct
else
echo
"External Power"
fi
}
function
battery_time_remaining
()
{
}
# Not available on android
function
battery_pct_prompt
()
{
local
battery_pct color
battery_pct
=
$(
battery_pct_remaining
)
if
battery_is_charging
;
then
echo
"∞"
else
if
[[
$battery_pct
-gt
50
]]
;
then
color
=
'green'
elif
[[
$battery_pct
-gt
20
]]
;
then
color
=
'yellow'
else
color
=
'red'
fi
echo
"%{
$fg
[
$color
]%}
${
battery_pct
}
%%%{
$reset_color
%}"
fi
}
elif
[[
"
$OSTYPE
"
=
linux
*
]]
;
then
elif
[[
"
$OSTYPE
"
=
linux
*
]]
;
then
function
battery_is_charging
()
{
function
battery_is_charging
()
{
if
((
$+
commands[acpitool]
))
;
then
if
((
$+
commands[acpitool]
))
;
then
...
@@ -163,46 +203,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
...
@@ -163,46 +203,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo
"%{
$fg
[
$color
]%}
${
battery_pct
}
%%%{
$reset_color
%}"
echo
"%{
$fg
[
$color
]%}
${
battery_pct
}
%%%{
$reset_color
%}"
fi
fi
}
}
elif
[[
"
$OSTYPE
"
=
linux-android
]]
&&
((
${
+commands[termux-battery-status]
}
))
;
then
function
battery_is_charging
()
{
termux-battery-status 2>/dev/null |
command awk
'/status/ { exit ($0 ~ /DISCHARGING/) }'
}
function
battery_pct
()
{
# Sample output:
# {
# "health": "GOOD",
# "percentage": 93,
# "plugged": "UNPLUGGED",
# "status": "DISCHARGING",
# "temperature": 29.0,
# "current": 361816
# }
termux-battery-status 2>/dev/null |
command awk
'/percentage/ { gsub(/[,]/,""); print $2}'
}
function
battery_pct_remaining
()
{
if
!
battery_is_charging
;
then
battery_pct
else
echo
"External Power"
fi
}
function
battery_time_remaining
()
{
}
# Not available on android
function
battery_pct_prompt
()
{
local
battery_pct color
battery_pct
=
$(
battery_pct_remaining
)
if
battery_is_charging
;
then
echo
"∞"
else
if
[[
$battery_pct
-gt
50
]]
;
then
color
=
'green'
elif
[[
$battery_pct
-gt
20
]]
;
then
color
=
'yellow'
else
color
=
'red'
fi
echo
"%{
$fg
[
$color
]%}
${
battery_pct
}
%%%{
$reset_color
%}"
fi
}
else
else
# Empty functions so we don't cause errors in prompts
# Empty functions so we don't cause errors in prompts
function
battery_is_charging
{
false
}
function
battery_is_charging
{
false
}
...
...
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