[Grml] Bugreport zshrc+acpi

Kai Wilke kiste at netzworkk.de
Thu Sep 18 12:54:15 CEST 2008


High, high ...
* Frank Terbeck <ft at grml.org> schrieb am [17.09.08 19:33]:
> Frank Terbeck <ft at grml.org>:
> [...]
> > [snip]
> > PERCENT=${${"$(acpi 2>/dev/null)"}/(#b)[[:space:]]##Battery <->: [^0-9]##, (<->)%*/${match[1]}}
> > [...]
> > 
> Well, I discussed this with mika on IRC.
> Unfortunately, this does work for him on the command line, but not in
> the zshrc file. I have got no idea why that is.

to works (my configuration /etc/zsh/zshrc):

line 943:
# display battery status on right side of prompt via running 'BATTERY=1 zsh'
# Benoetigt das paket acpi.
battery()
{
if [[ $BATTERY == 1 ]] ; then
    if check_com -c acpi ; then
        PERCENT=${${"$(acpi 2>/dev/null)"}/(#b)[[:space:]]##Battery <->: [^0-9]##, (<->)%*/${match[1]}}
        #PERCENT="${(C)${(s| |)$(acpi 2>/dev/null)}[4]}"
        [[ -z "$PERCENT" ]] && PERCENT='acpi not present'

        if [[ "$PERCENT" -lt 20 ]] ; then
            PERCENT="warning: ${PERCENT}%%"
        else
            PERCENT="${PERCENT}%%"
        fi
    fi
fi
}

see Var PERCENT and %%.

and Line 1036:


is4 && [[ -z $NOPRECMD || $NOPRECMD == 0 ]] && precmd () {
    [[ $NOPRECMD == 1 ]] && return 0
    # allow manual overwriting of RPROMPT
    if [[ -n $RPROMPT ]] ; then
        [[ $TERM == screen* ]] && echo -n $'\ekzsh\e\\'
        # return 0
    fi
    # just use DONTSETRPROMPT=1 to be able to overwrite RPROMPT
    if [[ -z $DONTSETRPROMPT || $DONTSETRPROMPT == 0 ]] ; then
        if [[ $BATTERY == 1 ]] ; then
            battery
            RPROMPT="%(?..:()% ${PERCENT}${SCREENTITLE}"
            # RPROMPT="${PERCENT}${SCREENTITLE}"
        elif [[ -n $VCS ]] ; then
            RPROMPT="%(?..:()% $(__vcs_dir)${SCREENTITLE}"
        else
            RPROMPT="%(?..:()% ${SCREENTITLE}"
            # RPROMPT="${SCREENTITLE}"
        fi
    fi
    # adjust title of xterm
    # see http://www.faqs.org/docs/Linux-mini/Xterm-Title.html
    case $TERM in
        (xterm*|rxvt)
            print -Pn "\e]0;%n@%m: %~\a"
            ;;
    esac
}

see precmd battery
> 
> [...]

mfg Kiste
-- 
#######################################################################
Netzworkk                   grml - Linux Live CD fuer Sysadmins
Kai Wilke                   http://grml.org
kiste at netzworkk.de
http://www.netzworkk.de
http://netzworkk.berlios.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://ml.grml.org/pipermail/grml/attachments/20080918/ce7d9c1d/attachment-0003.pgp>


More information about the Grml mailing list