projects
/
grml-etc-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
zshrc: support systems without capacity file in batterylinux() [Closes: issue1333]
[grml-etc-core.git]
/
etc
/
zsh
/
zshrc
diff --git
a/etc/zsh/zshrc
b/etc/zsh/zshrc
index
a7b70d2
..
0bf68f8
100644
(file)
--- a/
etc/zsh/zshrc
+++ b/
etc/zsh/zshrc
@@
-1761,7
+1761,13
@@
local batteries bat capacity
batteries=( /sys/class/power_supply/BAT*(N) )
if (( $#batteries > 0 )) ; then
for bat in $batteries ; do
batteries=( /sys/class/power_supply/BAT*(N) )
if (( $#batteries > 0 )) ; then
for bat in $batteries ; do
- capacity=$(< $bat/capacity)
+ if [[ -e $bat/capacity ]]; then
+ capacity=$(< $bat/capacity)
+ else
+ typeset -F energy_full=$(< $bat/energy_full)
+ typeset -F energy_now=$(< $bat/energy_now)
+ typeset -i capacity=$(( 100 * $energy_now / $energy_full))
+ fi
case $(< $bat/status) in
Charging)
GRML_BATTERY_LEVEL+=" ^"
case $(< $bat/status) in
Charging)
GRML_BATTERY_LEVEL+=" ^"