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
5fb204fa
Unverified
Commit
5fb204fa
authored
Oct 08, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(battery): force battery percentage as integer
parent
9aeb9675
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
battery.plugin.zsh
plugins/battery/battery.plugin.zsh
+4
-3
No files found.
plugins/battery/battery.plugin.zsh
View file @
5fb204fa
...
...
@@ -153,7 +153,7 @@ elif [[ "$OSTYPE" = linux* ]]; then
# Battery #1 : Unknown, 99.55%
# Battery #2 : Discharging, 49.58%, 01:12:05
# All batteries : 62.60%, 02:03:03
acpitool 2>/dev/null |
command awk
-F
,
'
local
-i
pct
=
$(
acpitool 2>/dev/null |
command awk
-F
,
'
/^\s+All batteries/ {
gsub(/[^0-9.]/, "", $1)
pct=$1
...
...
@@ -164,7 +164,8 @@ elif [[ "$OSTYPE" = linux* ]]; then
pct=$2
}
END { print pct }
'
'
)
echo
$pct
elif
((
$+
commands[acpi]
))
;
then
# Sample output:
# Battery 0: Discharging, 0%, rate information unavailable
...
...
@@ -227,7 +228,7 @@ function battery_level_gauge() {
local
charging_color
=
${
BATTERY_CHARGING_COLOR
:-
$color_yellow
}
local
charging_symbol
=
${
BATTERY_CHARGING_SYMBOL
:-
'⚡'
}
local
battery_remaining_percentage
=
$(
battery_pct
)
local
-i
battery_remaining_percentage
=
$(
battery_pct
)
local
filled empty gauge_color
if
[[
$battery_remaining_percentage
=
~
[
0-9]+
]]
;
then
...
...
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