Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
b23ccd67
Commit
b23ccd67
authored
Oct 26, 2016
by
Dylan Araps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Battery: [Linux] Rewrite battery
parent
931660d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
36 deletions
+17
-36
neofetch
neofetch
+17
-36
No files found.
neofetch
View file @
b23ccd67
...
...
@@ -1618,44 +1618,25 @@ getdisk() {
getbattery() {
case "
$os
" in
"
Linux
")
if [ "
$(
ls
/sys/class/power_supply/
)
" ]; then
# Set the index to the battery number.
case "
$battery_num
" in
"
all
") battery_num="
*
" index=0 ;;
*) index="
$battery_num
" ;;
esac
# We use 'prin' here and exit the function early so that we can
# do multi battery support with a single battery per line.
if [ -f /sys/class/power_supply/**/capacity ]; then
for bat in "
/sys/class/power_supply/BAT
"*; do
capacity="
$(
<
${
bat
}
/capacity
)
"
status="
$(
<
${
bat
}
/status
)
"
battery="
${
capacity
}
% [
${
status
}
]
"
case "
$battery_display
" in
"
bar
") battery="
$(
bar
"
$capacity
"
100
)
" ;;
"
infobar
") battery+="
$(
bar
"
$capacity
"
100
)
" ;;
"
barinfo
") battery="
$(
bar
"
$capacity
"
100
)
${
battery
}
" ;;
esac
batteries=("
$(
cat
/sys/class/power_supply/BAT
$battery_num
/capacity
)
")
battery_state=("
$(
cat
/sys/class/power_supply/BAT
${
battery_num
}
/status
)
")
# Get the subtitle and reassign it so it doesn't change.
title="
$subtitle
"
# If shorthand is on, print each value on the same line
if [ "
$battery_shorthand
" == "
on
" ]; then
battery="
${
batteries
[*]
}
"
battery="
${
battery
// /%,
}
"
battery="
${
battery
}
%
"
else
if [ "
${#
batteries
[@]
}
" -gt 1 ]; then
unset battery
# Print each battery on a separate line.
for bat in "
${
batteries
[@]
}
"; do
case "
$battery_display
" in
"
bar
") prin "
${
title
}${
index
:-
0
}
" "
$(
bar
"
${
bat
/
'%'
}
"
100
)
" ;;
"
infobar
") prin "
${
title
}${
index
:-
0
}
" "
${
bat
}
%
$(
bar
"
${
bat
/
'%'
}
"
100
)
" ;;
"
barinfo
") prin "
${
title
}${
index
:-
0
}
" "
$(
bar
"
${
bat
/
'%'
}
"
100
)
${
bat
}
%
" ;;
*) prin "
${
title
}${
index
:-
0
}
" "
${
bat
}
%
" ;;
esac
index="
$((
index+
=
1
))
"
done
return
fi
battery="
${
batteries
[0]
}
%
"
fi
prin "
${
subtitle
}${
bat
:
-1
}
" "
$battery
"
done
fi
unset battery
return
;;
"
BSD
")
...
...
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