I do some change on the bash script that I've posted few days ago. This works better. It must be in the .bashrc.
.,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,. # Color the bash prompt in function of the percentage of battery # with acpi subsystem. # Based on the originally apm based script that has been posted # on debian-laptop by Jason Kraftcheck <[EMAIL PROTECTED]>. # # This script is licensed under the GNU GPL version 2 or later, # see /usr/share/common-licences/GPL on a Debian system or # http://www.gnu.org/copyleft/gpl.html on the web. # (c) 2003 Fabio 'farnis' Sirna <[EMAIL PROTECTED]> function acpi_percent() { if [ `cat /proc/acpi/battery/BAT0/state | grep present: |cut -d\ -f18` = "yes" ]; then { CAPACITY=`cat /proc/acpi/battery/BAT0/info |grep "design capacity:"|cut -d\ -f11` LEVEL=`cat /proc/acpi/battery/BAT0/state | grep remaining|cut -d\ -f8` ACPI_PERCENT=`echo $(( $LEVEL * 100 / $CAPACITY ))` if [ "$LEVEL" = "$CAPACITY" ]; then echo FULL else echo $ACPI_PERCENT% fi } else echo "NO BATTERY" fi } function acpi_charge() { ACPI_CHARGE=`cat /proc/acpi/ac_adapter/AC/state | cut -d\ -f20` case $ACPI_CHARGE in *on-line*) ACPI_CHARGE="+" ;; *off-line*) ACPI_CHARGE="-" ;; esac echo $ACPI_CHARGE } function acpi_color() { if [ "$(acpi_charge)" = "+" ]; then { if [ `cat /proc/acpi/battery/BAT0/state | grep present: |cut -d\ -f18` = "no" ]; then echo "0;31" else echo "1;32" fi } else case $(acpi_percent) in 10?%) echo "0;32" ;; 9?%) echo "0;32" ;; 8?%) echo "0;32" ;; 7?%) echo "0;32" ;; 6?%) echo "0;32" ;; 5?%) echo "0;32" ;; 4?%) echo "0;33" ;; 3?%) echo "0;33" ;; 2?%) echo "0;33" ;; 1?%) echo "0;31" ;; ?%) echo "0;31;5" ;; *) echo "0;35" ;; esac fi } function acpi_color_prompt { PS1='\[\e[$(acpi_color)m\][$(acpi_charge)$(acpi_percent)][\t] \u:\w\$>\[\e[0;37m\] ' #PS1="\[\e[$(acpi_color)m\]\h\$\[\e[0m\] " } # linux console if [ "$TERM" = "linux" ]; then PROMPT_COMMAND=acpi_color_prompt fi function echo_acpi { echo -n "($(acpi_charge)$(acpi_percent)) " } .,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,. -- Fabio _____________________________________________________________________ Envie de discuter en "live" avec vos amis ? Télécharger MSN Messenger http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France