update to the battery meter script to add to your prompt. Took something I found online and did a re-write. Name it and call it from your .bashrc as described above, or write as a function directly in your .bashrc.
Code: Select all
#! /bin/bash
# battery status script
BATTERY=/sys/class/power_supply/BAT0
CAPACITY=`cat $BATTERY/capacity`
STATE=`cat $BATTERY/status`
NON='\033[00m'
BLD='\033[01m'
RED='\033[01;31m'
GRN='\033[01;32m'
YEL='\033[01;33m'
COLOR="$RED"
case "${STATE}" in
'Full')
STATE="$BLD*$NON"
;;
'Charging')
STATE="$BLD+$NON"
;;
'Discharging')
STATE="$BLD-$NON"
;;
esac
# color code capacity
if [ "$CAPACITY" -gt "99" ]
then
CHARGE=100
fi
if [ "$CAPACITY" -gt "15" ]
then
COLOR="$YEL"
fi
if [ "$CAPACITY" -gt "30" ]
then
COLOR="$GRN"
fi
echo -e "${COLOR}${CAPACITY}${NON}${STATE}"
# end
EDIT - fixed a couple of errors. Fixed the CHARGED variable and 'Charged' to 'Full' in the case statement.
EDIT 2 - more clean up, less bloat :)
place in .bashrc prompt code
Code: Select all
PS1="\[\033[0;37m\]\][\$(/path/to/script/battstat2.sh)\033[0;37m\]]-[\[\033[0;31m\]\[\A\[\033[0;37m\]]-[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\224\200\342\224\200\342\225\274 \[\033[0m\]"
charging
discharging