maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Support thread] Billboard Standby Screen (https://talk.maemo.org/showthread.php?t=84507)

herno24 2013-01-04 00:41

Re: [Support thread] Billboard Standby Screen
 
There is an error in this script, it doesn't show nothing when data left <20%. Maybe that's why my modification doesn't work.

Quote:

Originally Posted by thedead1440 (Post 1309420)
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...


thedead1440 2013-01-04 01:14

Re: [Support thread] Billboard Standby Screen
 
herno24, i haven't looked at your modification but what i did worked for me, did you install bc and have dc already? If you don't have bc it wont work...

herno24 2013-01-04 01:29

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thedead1440 (Post 1310686)
herno24, i haven't looked at your modification but what i did worked for me, did you install bc and have dc already? If you don't have bc it wont work...

I installed only the .deb that you attached.

Edit: I had not installed dc, but now it doesn't show nothing. Before installing dc I could see the MB consumed.

herno24 2013-01-04 02:22

Re: [Support thread] Billboard Standby Screen
 
Ok, i can see 248MB consumed in cyan but it should be displayed in red (because i have a total of 300 MB). Maybe an error in amount or in the IF condition?. This is my modification code:

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))
consumed=$((total/1000000))
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}}$consumed MB"
else
echo "{{cyan}}$consumed MB"
fi
exit 1


thedead1440 2013-01-04 02:58

Re: [Support thread] Billboard Standby Screen
 
herno24,

My script for what you want:
Code:

#!/bin/sh

# Warn in red if data left <20%

# Data usage in cyan if data left not <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)
totalMB=$((($tx+$rx)/1000000))
amount=`dc $total $usage / p`

if [ $(echo "$amount > 0.800" |bc) -eq 1 ]
then
echo {{red}}"Data left < 20%"
else
echo {{cyan}}"Data used = $totalMB MB"
fi
exit 1

Screenshots:

http://db.tt/nPDeajjI

http://db.tt/SAaJZR4J


Edit: I hadn't read thp's post in the previous page; you can remove the {{cyan}} tag and add it to billboard instead so your data usage will be shown in whatever colour you want while the <20% warning will be in red always...

herno24 2013-01-04 03:09

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thedead1440 (Post 1310706)
herno24,

My script for what you want:
Code:

#!/bin/sh

# Warn in red if data left <20%

# Data usage in cyan if data left not <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)
totalMB=$((($tx+$rx)/1000000))
amount=`dc $total $usage / p`

if [ $(echo "$amount > 0.800" |bc) -eq 1 ]
then
echo {{red}}"Data left < 20%"
else
echo {{cyan}}"Data used = $totalMB MB"
fi
exit 1


I don't know why, but it doesn't work. I installed bc from your attachment and dc via terminal (apt-get install dc), is that correct?.

thedead1440 2013-01-04 03:10

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by herno24 (Post 1310709)
I don't know why, but it doesn't work. I installed bc from your attachment and dc via terminal (apt-get install dc), is that correct?.

Yes...

10chars

P.S. did you chmod 775 your sh file and is it in /home/user/ ?


Edit 2: Do a sh /path/to/script as user in terminal to see if the output satisfies what you want before putting it into Billboard...

herno24 2013-01-04 03:26

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thedead1440 (Post 1310710)
Edit 2: Do a sh /path/to/script as user in terminal to see if the output satisfies what you want before putting it into Billboard...

This is the result:
Code:

#!/bin/sh: not found
dc: Could not open file 242418745
dc: Could not open file 1000000000
dc: Will not attempt to process directory /
dc: Could not open file p
(standard_in) 1: syntax error
sh: 1: unknown operand
{{cyan}}Data used = 242 MB


thedead1440 2013-01-04 03:31

Re: [Support thread] Billboard Standby Screen
 
Can you do a dc of those values manually in terminal not via sh script? Also why would it say #!/bin/sh not found? Is your text editor putting it correct? Why not just use vi(m) or nano on the phone via ssh otherwise to rule out your text editor...

herno24 2013-01-04 03:40

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thedead1440 (Post 1310713)
Can you do a dc of those values manually in terminal not via sh script?

Like this?:
Code:

~ $ usage=$(gconftool -g /cellui/settings/datac
ounter/general/gprs_home_notification_period_UI)
~ $ totalMB=$((($tx+$rx)/1000000))
-/bin/sh: arithmetic syntax error
~ $ `dc $total $usage / p`
dc: Could not open file 1000000000
dc: Will not attempt to process directory /
dc: Could not open file p



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

vBulletin® Version 3.8.8