Active Topics

 



Notices


Reply
Thread Tools
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#551
Originally Posted by Win7Mac View Post
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.
 

The Following 3 Users Say Thank You to thp For This Useful Post:
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#552
Originally Posted by thp View Post
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.
__________________
Nokia 5110 > 3310 > 6230 > N70 > N9 BLACK 64GB
Hildon Foundation Board member
Maemo Community e.V. co-creator, founder and director since Q4/2016
Current Maemo Community Council member
 
Posts: 4 | Thanked: 0 times | Joined on Jun 2012
#553
Originally Posted by slarti View Post
BUT, when I changed the title of my alarm "Herätys" to "Heratys" it magically showed up in Billboard, too!

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's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#554
Originally Posted by Hid45 View Post
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.
 
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#555
Originally Posted by Win7Mac View Post
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

Last edited by thedead1440; 2013-01-27 at 09:31. Reason: typo
 

The Following User Says Thank You to thedead1440 For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,701 times | Joined on Nov 2011 @ Ängelholm, Sweden
#556
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??
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#557
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...
 

The Following User Says Thank You to thedead1440 For This Useful Post:
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#558
Originally Posted by thedead1440 View Post
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.
__________________
Nokia 5110 > 3310 > 6230 > N70 > N9 BLACK 64GB
Hildon Foundation Board member
Maemo Community e.V. co-creator, founder and director since Q4/2016
Current Maemo Community Council member
 
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#559
Originally Posted by Win7Mac View Post
Here, the " -n" was missing. Got it now, thanks.
-n do not output the trailing newline
So not really required
 
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#560
Originally Posted by thedead1440 View Post
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?
__________________
Nokia 5110 > 3310 > 6230 > N70 > N9 BLACK 64GB
Hildon Foundation Board member
Maemo Community e.V. co-creator, founder and director since Q4/2016
Current Maemo Community Council member

Last edited by Win7Mac; 2013-01-27 at 12:29.
 
Reply


 
Forum Jump


All times are GMT. The time now is 00:06.