si integra molto bene nella variabile PS1 oppure direttamente come comando..

anche questo è scaricabile da qua

#!/bin/bash
#
# bat_mon.sh
#
# dj@swicked.net
#
# This is a script I wrote so that I could have a sort of battery monitor at
# the command line, since that is where I live most of the time. Also, I run
# fluxbox because it’s light weight with no eye candy. I tried things like
# torsmo and gkrellm for monitoring the battery, but they defeated the purpose
# of using fluxbox.
#
# This script is meant for usage in your $PS1 variable. I added colors to this
# so that (a) the battery level would stand out and (b) so that you can quickly
# know the state of the battery level. When the laptop is on AC power, then no
# matter what the level of your battery, it will display in cyan. Once you are
# on battery power, the display will be either green, yellow, or red, depending
# on the remaining charge left in the battery. Simply add this part somewhere
# in your $PS1:
#
#    \[\$(path/to/bat_mon.sh)\]
#
# Here is what my $PS1 looks like in my .profile just as an example:
#
#    export PS1=”\[\$(/usr/local/bin/bat_mon.sh)\]\W \\$ ”
#
# Of course you can change the colors and/or alert levels to whatever you like.
# That’s it. Enjoy it or hate it
#
# $Id: bat_mon.sh,v 1.5 2005/12/20 17:02:28 dj Exp $
#

full=`grep full /proc/acpi/battery/BAT0/info | awk -F’ ‘ ‘{print $4}’`
remaining=`grep remaining /proc/acpi/battery/BAT0/state | awk -F’ ‘ ‘{print $3}’`
state=`grep ‘charging state’ /proc/acpi/battery/BAT0/state | awk -F’ ‘ ‘{print $3}’`

percentage=$(($remaining*100/$full))

if [ $state == ‘charged’ ]
then
# if we are fully charged, say so in blue
echo -e “33[01;34m$state33[0m ”
elif [ $state == ‘charging’ ]
then
# if we are charging up, show the state and
# what percentage it’s at in cyan
echo -e “33[01;36mAC $percentage%33[0m ”
elif [ $percentage -gt 50 ]
then
# if the battery level is 51% or above, we’re ok
# so display in green
echo -e “33[01;32m$percentage%33[0m ”
elif [ $percentage -gt 20 ]
then
# if the battery level is 21% or above, we’re getting low
# so display in yellow
echo -e “33[01;33m$percentage%33[0m ”
elif [ $percentage  -gt 0 ]
then
# if the battery is level is below that 20%, it’s getting
# critical, so display in red
echo -e “33[01;31m$percentage%33[0m ”
fi

Advertisements