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
37662132
Commit
37662132
authored
Oct 26, 2016
by
Dylan Araps
Committed by
GitHub
Oct 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #397 from dylanaraps/bat
Battery: [Linux] Rewrite battery
parents
931660d3
72de6686
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
51 deletions
+17
-51
config
config/config
+0
-15
neofetch
neofetch
+17
-36
No files found.
config/config
View file @
37662132
...
@@ -161,21 +161,6 @@ gtk2="on"
...
@@ -161,21 +161,6 @@ gtk2="on"
gtk3
=
"on"
gtk3
=
"on"
# Battery
# Which battery to display.
# By default we display all batteries.
# NOTE: Only works on Linux.
# --battery_num all, 0, 1, 2, etc
battery_num
=
"all"
# Whether or not to print each battery on the same line.
# By default each battery gets its own line and title.
# NOTE: Only works on Linux.
# --battery_shorthand on, off
battery_shorthand
=
"off"
# IP Address
# IP Address
# Website to ping for the public IP
# Website to ping for the public IP
...
...
neofetch
View file @
37662132
...
@@ -1618,44 +1618,25 @@ getdisk() {
...
@@ -1618,44 +1618,25 @@ getdisk() {
getbattery() {
getbattery() {
case "
$os
" in
case "
$os
" in
"
Linux
")
"
Linux
")
if [ "
$(
ls
/sys/class/power_supply/
)
" ]; then
# We use 'prin' here and exit the function early so that we can
# Set the index to the battery number.
# do multi battery support with a single battery per line.
case "
$battery_num
" in
if [ -f /sys/class/power_supply/**/capacity ]; then
"
all
") battery_num="
*
" index=0 ;;
for bat in "
/sys/class/power_supply/BAT
"*; do
*) index="
$battery_num
" ;;
capacity="
$(
<
${
bat
}
/capacity
)
"
esac
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
)
")
prin "
${
subtitle
}${
bat
:
-1
}
" "
$battery
"
battery_state=("
$(
cat
/sys/class/power_supply/BAT
${
battery_num
}
/status
)
")
done
# 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
fi
fi
unset battery
return
;;
;;
"
BSD
")
"
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