Re: indicatore batteria
Alle giu 20 at 07:06, Alessandro Riz scrisse:
>Ciao a tutti,
> Sapete se c'e' programma che mi dica la carica della
>batteria e che funzioni in modalita' testo?
salva lo script che ti ho postato in .bash_acpi_prompt e metti in
.bashrc la seguente riga:
source ~/.bash_acpi_prompt
In questo modo avrai il prompt con l'indicazione di carica, e colorato
in base alla carica.
.,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,..,-''-,.
# 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 <kraftche@cae.wisc.edu>.
#
# 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 <farnis AT libero DOT it>
#
# put in your .bashrc the next line:
#
# source ~/.bash_acpi_prompt
# acpi_color_prompt
#
#
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`
CAPACITY=3520
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\] '
}
# 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
Reply to: