View Single Post
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#402
EmaNymton,

Would a sh script instead make the readout faster?

I did a simple sh script for the same and it worked too:
Code:
#!/bin/sh

# Get GPRS transmission

tx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_tx_bytes)
rx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_rx_bytes)
txMB=$(($tx/1000000))
rxMB=$(($rx/1000000))

echo "up: $txMB MB, down: $rxMB MB"
I didn't include decimal places so its a whole number though...


Edit: Another one just printing total usage:

Code:
#!/bin/sh

# Get total GPRS transmission in MB

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)/1000000))

echo "Data used = $total MB"

Edit 2: Warn in red if data left is <20%:
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`

if [ $(echo "$amount > 0.800" |bc) -eq 1 ]
then
echo {{red}}"Data left < 20%"
fi
exit 1
bc is required for the above but since harmattan-dev is down; its on my db...

Last edited by thedead1440; 2012-12-31 at 15:21.
 

The Following 4 Users Say Thank You to thedead1440 For This Useful Post: