[issue1333] grml zshrc used on Linux 3.2 (e.g. Wheezy) shows before each prompt "batterylinux:6: no such file or directory: /sys/class/power_supply/BAT0/capacity"
Axel Beckert
bts at bts.grml.org
Sun Dec 7 02:37:10 CET 2014
Axel Beckert <abe at deuxchevaux.org> added the comment:
Hi,
On Sun, Dec 07, 2014 at 12:52:16AM +0000, Axel Beckert wrote:
> batterylinux:6: no such file or directory: /sys/class/power_supply/BAT0/capacity
The following patch seems to fix this issue:
diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
index d3d73b1..ae2f8af 100644
--- a/etc/zsh/zshrc
+++ b/etc/zsh/zshrc
@@ -1674,7 +1674,13 @@ local batteries bat capacity
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+=" ^"
There are though some syntax issues if running on Wheezy, too, but
likely due to zsh 4.3.17 and not due to kernel 3.2.x. The following
patch fixes them -- I can open a separate issue for that if wanted:
diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
index d3d73b1..ae2f8af 100644
--- a/etc/zsh/zshrc
+++ b/etc/zsh/zshrc
@@ -1129,7 +1129,7 @@ help_zle_parse_keybindings()
if [[ -r $HELP_ZLE_CACHE_FILE ]]; then
local load_cache=0
- for f ($HELPZLE_KEYBINDING_FILES) [[ $f -nt $HELP_ZLE_CACHE_FILE ]] && load_cache=1
+ for f ($HELPZLE_KEYBINDING_FILES); do [[ $f -nt $HELP_ZLE_CACHE_FILE ]] && load_cache=1; done
[[ $load_cache -eq 0 ]] && . $HELP_ZLE_CACHE_FILE && return
fi
@@ -2934,7 +2940,7 @@ ssl-cert-info() {
}
# make sure our environment is clean regarding colors
-for color in BLUE RED GREEN CYAN YELLOW MAGENTA WHITE ; unset $color
+for color in BLUE RED GREEN CYAN YELLOW MAGENTA WHITE ; do unset $color; done
# "persistent history"
# just write important commands you always need to ~/.important_commands
@@ -3406,7 +3412,7 @@ if check_com -c hg ; then
#f5# GNU like diff for mercurial
hgdi() {
emulate -L zsh
- for i in $(hg status -marn "$@") ; diff -ubwd <(hg cat "$i") "$i"
+ for i in $(hg status -marn "$@") ; do diff -ubwd <(hg cat "$i") "$i"; done
}
# build debian package
Kind regards, Axel
--
/~\ Plain Text Ribbon Campaign | Axel Beckert
\ / Say No to HTML in E-Mail and News | abe at deuxchevaux.org (Mail)
X See http://www.nonhtmlmail.org/campaign.html | abe at noone.org (Mail+Jabber)
/ \ I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)
----------
messages: 4913, 4914
nosy: abe
priority: wish
status: chatting
title: grml zshrc used on Linux 3.2 (e.g. Wheezy) shows before each prompt "batterylinux:6: no such file or directory: /sys/class/power_supply/BAT0/capacity"
topic: configs, grml-etc-core, zsh
_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue1333>
_____________________________________
More information about the Bugs-changes
mailing list