Notices


Reply
Thread Tools
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#401
I wrote a little script to show the used traffic, have fun!

Edit: Forgot to mention that python-gconf must be installed.
Edit2: The script could be optimized, especially the format of the shown digits depending on the values and maybe changing the string color to red, if a predefined value is going to be exceeded.
I have not much time today, but will try it tomorrow...

Code:
#!/usr/bin/python
#-*- coding: utf-8 -*-

import gconf
import sys

client = gconf.client_get_default()
tx_bytes = client.get_string('/cellui/settings/datacounter/transfer/gprs_home_tx_bytes')
rx_bytes = client.get_string('/cellui/settings/datacounter/transfer/gprs_home_rx_bytes')
output_string = "up: {tx:03.2f} MB, down: {rx:03.2f} MB".format(tx=float(tx_bytes)/1000000,
                                                          rx=float(rx_bytes)/1000000)
sys.stdout.write(output_string)
Attached Images
 

Last edited by EmaNymton; 2012-12-31 at 13:00.
 

The Following 5 Users Say Thank You to EmaNymton For This Useful 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:
bibek's Avatar
Posts: 368 | Thanked: 826 times | Joined on May 2012 @ India
#403
Any way to set custom fonts for BillBoard text? Any css file to edit manually?
 

The Following User Says Thank You to bibek For This Useful Post:
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#404
Originally Posted by bibek View Post
Any way to set custom fonts for BillBoard text? Any css file to edit manually?
Code:
gconftool -s -t string /apps/billboard/font "Comic Sans MS"
 

The Following 3 Users Say Thank You to thp For This Useful Post:
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#405
Scripts repository updated with data usage scripts here. You can submit scripts by posting the code here in this thread or by sending a pull request on Github. Thanks for your contributions so far
 

The Following 2 Users Say Thank You to thp For This Useful 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:
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#407
Originally Posted by herno24 View Post
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.
Some feedback on that: In general, it's a good idea when writing shell scripts to quote as much as possible to avoid side-effects, because { and } are interpreted in a special way:

Code:
echo M{aem,eeG}o
Versus:

Code:
echo "M{aem,eeG}o"
So this might be better:

Code:
echo "{{red}}$consumed MB"
Also, you don't have to hardcode {{cyan}} in the script - you can put it in Billboard before the {script:} call, e.g.:

Code:
{{cyan}}{script:/path/to/my/script.sh}
If the script doesn't add the {{red}}, {{cyan}} will be in effect, otherwise {{cyan}} will be overridden by {{red}}. This allows you to change cyan to some other color inside the Billboard configuration utility without having to edit the script again.
 

The Following 6 Users Say Thank You to thp For This Useful Post:
Posts: 443 | Thanked: 282 times | Joined on Oct 2011 @ Grenoble, France
#408
Originally Posted by herno24 View Post
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
I have a problem with your script thedead. Nothing is displayed by bilboard ... and if I make : sh "your script"
I get
No value set for /cellui/settings/datacounter/transfer/gprs_home_tx_bytes.
Any ideas?

Edit: my mistake a "y" has been introduced during my difficult work to copy the script lol

Last edited by mousse04; 2013-01-03 at 22:11.
 
Posts: 87 | Thanked: 14 times | Joined on Jan 2012
#409
Ok, i don't know if there is a problem in the if condition, becasuse if i change reply = (echo "$amount > 0.800") to > 0.200, it should show the MB amount in red (because I have consumed 148 of 300 MB), but I still see the MB amount in color cyan.
 
Posts: 87 | Thanked: 14 times | Joined on Jan 2012
#410
@thp This is not working, on 240 of 300 MB consumed, it should show this amount in red, but it shows this amount in cyan.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 13:40.