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)

thp 2013-01-25 08:18

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by Win7Mac (Post 1317460)
echo -n "{{yellow}} $percent % " "{{=0.$percent}}"

This will turn into {{=0.(whatever percent is)}}, so for 13% it will be {{=0.13}, for 75% it will be {{=0.75}} and for 100% it will be {{=0.100}}, aka 0.1, aka 10% (instead of 100). Also, for 3% it will be {{=0.3}}, which is also wrong.

Assuming you don't have a shell that can calculate in floating point, a better solution would be would be:

echo "{{=$((PERCENT/100)).$(((PERCENT%100)/10))$((PERCENT%10))}}"

This will work for all positive integers.

Win7Mac 2013-01-25 22:05

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thp (Post 1317600)
echo "{{=$((PERCENT/100)).$(((PERCENT%100)/10))$((PERCENT%10))}}"

since I suck so bad at coding, I couldn't get it to work. How is it correctly incorporated into this script?

Anybody up for a data network signal-% script?

Thanks so much.

Hid45 2013-01-26 13:10

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by slarti (Post 1222606)
BUT, when I changed the title of my alarm "Herätys" to "Heratys" it magically showed up in Billboard, too!:D

So, it seems that Billboard can't show scandinavian letters.

edit: It doesn't show scandinavian letters from scripts. They show up just fine if I write them directly to the input field in Billboard. Should the output from the script be encoded somehow?

I'm having the same problem. Scandics work in free text and for example from meecast-station, but when I'm trying to print scandics to Billboard using my own scripts, it doesn't work.

Any suggestions? I'm trying to print from txt-file (for nameday.sh), encoding issues perhaps?

thp 2013-01-27 09:18

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by Hid45 (Post 1317950)
Any suggestions? I'm trying to print from txt-file (for nameday.sh), encoding issues perhaps?

Yes, make sure your script is UTF-8 encoded.

thedead1440 2013-01-27 09:27

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by Win7Mac (Post 1317818)
since I suck so bad at coding, I couldn't get it to work. How is it correctly incorporated into this script?

Anybody up for a data network signal-% script?

Thanks so much.

Code:

#!/bin/sh

percent=$(qdbus --system com.nokia.csd /com/nokia/csd/csnet com.nokia.csd.CSNet.SignalStrength.SignalPercent)
if [[ $percent -ge 25 ]]
then
echo -n "{{yellow}} $percent % " "{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}"
else if [[ $percent -le 24 ]]
then
echo -n "{{red}} $percent % " "{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}"
fi
fi


thp meant to tell you that in place of PERCENT use your variable which is $percent in this case; simples and 0 coding knowledge required ;)

coderus 2013-01-27 10:17

Re: [Support thread] Billboard Standby Screen
 
Code:

$percent % " "{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}
 $percent % " "{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}
 $percent % " "{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}
 $percent % " "{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}

how many times you want to copy so long line again and again?
why not to write short and beaty scripts as here??

thedead1440 2013-01-27 10:35

Re: [Support thread] Billboard Standby Screen
 
coderus,

Your script has the same fallacy from the looks of it whereby anything below 10% is not shown properly for example 3% becomes 0.3 i.e. 30% bar while thp's method accounts for single integers and 100% too...

Win7Mac 2013-01-27 11:10

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thedead1440 (Post 1318077)
thp meant to tell you that in place of PERCENT use your variable which is $percent in this case; simples and 0 coding knowledge required ;)

Here, the " -n" was missing. Got it now, thanks.

thedead1440 2013-01-27 11:20

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by Win7Mac (Post 1318099)
Here, the " -n" was missing. Got it now, thanks.

Quote:

-n do not output the trailing newline
So not really required ;)

Win7Mac 2013-01-27 11:28

Re: [Support thread] Billboard Standby Screen
 
Quote:

Originally Posted by thedead1440 (Post 1318101)
So not really required ;)

True, works without -n too.

Also I'm using this script to show uptime in decimal numbers:
Code:

#!/usr/bin/python
# Show Device Uptime in decimal days

sc = u"\u2622"
seconds = int(float(open('/proc/uptime').read().split()[0]))
print 'up: '+("%.1f" % (float(seconds)/float(60*60*24))).replace('.', ',')+' d'+' '+sc.encode('utf-8')

Now I want it to show the after decimal point only when upime is <10 days.
So that it would print "9,9 days" and "10 days".
Could someone put that rule to the script please?


All times are GMT. The time now is 01:08.

vBulletin® Version 3.8.8