View Single Post
Posts: 87 | Thanked: 14 times | Joined on Jan 2012
#406
I modified the last thedead1440's script to display the amount of MB consumed in red if they reach 80% of total MB or else in cyan if this value is not reached. I don't know how to program in this language so what I did must be very ugly haha, but is it correct?. Thanks!.

Code:
#!/bin/sh

# Warn in red if data left <20%

tx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_tx_bytes)
rx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_rx_bytes)
total=$(($tx+$rx))
usage=$(gconftool -g /cellui/settings/datacounter/general/gprs_home_notification_period_UI)
amount=`dc $total $usage / p`

consumed=$((total/1000000))
reply= (echo "$amount > 0.800" |bc)

if [ $(reply) -eq 1 ]
then
echo {{red}}"$consumed MB"
else
echo {{cyan}}"$consumed MB"
fi
exit 1
 

The Following User Says Thank You to herno24 For This Useful Post: