[Linux-Biella] apm console status
Paul TT
linux@bilug.linux.it
Sun, 29 Jun 2003 15:26:38 +0200
ho scritto 'sta funzioncina, - da un'idea di un mio amico di milano,
raffaele, - che costruisce una variabile contenente la carica della
batteria e lo stato, (se in batteria o attaccato alla corrente),
leggendo le informazioni in /proc/apm.
io infilo poi la funzione stessa nel prompt PS1, cosi' a ogni invio
nella shell mi dice come sto.
la funzione stessa andrebbe infilata in .bashrc, o in un posto in cui
esporti le variabili d'ambiente (io ho tutto in /etc/profile.d/profile,
ad esempio...). appiccico pure un esempio del mio prompt. sto file qua
e' anche su http://www.paultt.org/downloads/scripts/bashrc_apm
====8<-----------
###### apm code
function ptt_apm() {
A=`cat /proc/apm`
P=`echo $A | cut -d" " -f7-9`
if [ "`echo $A | cut -d" " -f4`" = "0x01" ]; then
P="[1;34;34m[AC `echo $P | cut -d" " -f1`]"
else
case `echo $P | cut -d" " -f1` in
4?%|3?%|2?%)
P="[0;33m[DC $P]" ;;
1?%)
P="[0;33;7m[DC $P]" ;;
?%)
P="[0;31;7m[DC $P]" ;;
*)
P="[0;32m[DC $P]" ;;
esac
fi
echo $P
}
export PS1="\033[36;1m\]\t \d\[\033[34m \033\$(ptt_apm)\033[m
\033[33;1m\]\u@\h \[\033[1;32m\]\w\[\033[1m\]\n\[\033[m\]$ "
====8<-----------
--
"...Been around this world so many times,
if you could only see my mind..."