#!/bin/bash
PTOT=$(</sys/class/power_supply/BAT1/charge_full)
PNOW=$(</sys/class/power_supply/BAT1/charge_now)
PERCR=$(echo "$PNOW / $PTOT * 100" | bc -l)
PERCS=${PERCR:0:2}
PERC=${PERCS#0}
LOWPOWER=20
if [ $PERC -lt $LOWPOWER ]
then
echo -en "\033[1;31m"
fi
echo -n $PERC%
if [ $PERC -lt $LOWPOWER ]
then
echo -en "\033[0m"
fi
Comments