Notices


Reply
Thread Tools
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#641
Originally Posted by slarti View Post
the condition you're looking for is:

Code:
if [$percent -eq -1]
then echo -n "flightmode on"
fi
Or something like that...
Doesn't work, still looks like in the picture above.
So you're absolutely right, must be something like that...
__________________
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: 277 | Thanked: 319 times | Joined on Jan 2010
#642
Exactly. That was off the top of my head. How do you test for -1 in sh? Because that's what the percentage is when in flight mode.
 
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#643
Originally Posted by slarti View Post
Exactly. That was off the top of my head. How do you test for -1 in sh? Because that's what the percentage is when in flight mode.
I edited the sript to
Code:
#!/bin/sh

percent=$(qdbus --system com.nokia.csd /com/nokia/csd/csnet com.nokia.csd.CSNet.SignalStrength.SignalPercent)
if [[ $percent -ge 25 ]]
then printf "{{yellow}}{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}"
else if [[ $percent -le 24 ]]
then printf "{{red}}{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}"
else if [[$percent -eq -1]]
then echo -n "{{red}}flightmode on"
fi
fi
fi
E: But it's not working...
__________________
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-02-18 at 18:50.
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#644
this is how my signal bar script looks like:
Code:
#!/bin/sh

percent=$(qdbus --system com.nokia.csd /com/nokia/csd/csnet com.nokia.csd.CSNet.SignalStrength.SignalPercent)
if [ $percent -eq -1 ]; then percent=0; fi
echo -n "{{white}}"
echo -n $percent
color="green"
if [ $percent -le 50 ]; then color="yellow"; fi
if [ $percent -le 20 ]; then color="red"; fi
echo -n "% {{$color}}{{="
echo -n $(($percent/100)).$((($percent%100)/10))$(($percent%10))
echo -n "}}"
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#645
Originally Posted by coderus View Post
this is how my signal bar script looks like
Fantastic.
What would it look like if it was supposed to show "flightmode" instead of the bar when flightmode is active?
__________________
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
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#646
replace line to
Code:
if [ $percent -eq -1 ]; then echo -n "flight mode"; exit; fi
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following User Says Thank You to coderus For This Useful Post:
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#647
Originally Posted by Win7Mac View Post
E: But it's not working...
The reason it's not working is that you're evaluating first if something is greater or equal to 25. If it isn't, then you evaluate if it's lower or equal to 24. -1 is lower than 24 so that's what your script picks. It never gets around to evaluating if it's -1. So put that evaluation first. Also, add spaces around the evaluation and correct my mistake.

or something like that...
 

The Following User Says Thank You to slarti For This Useful Post:
Win7Mac's Avatar
Community Council | Posts: 664 | Thanked: 1,648 times | Joined on Apr 2012 @ Hamburg
#648
Originally Posted by slarti View Post
The reason it's not working is that you're evaluating first if something is greater or equal to 25.
If it isn't, then you evaluate if it's lower or equal to 24.
So that's the difference between "if" and "else if"?

And yeah, that did the trick, great!
Nice, a new feature out of a failure...
Here it is:
Code:
#!/bin/sh

percent=$(qdbus --system com.nokia.csd /com/nokia/csd/csnet com.nokia.csd.CSNet.SignalStrength.SignalPercent)
if [[ $percent -eq -1 ]]
then echo -n "{{red}}Flightmode on"
else if [[ $percent -ge 25 ]]
then printf "{{yellow}}{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}"
else if [[ $percent -le 24 ]]
then printf "{{red}}{{=$(($percent/100)).$((($percent%100)/10))$(($percent%10))}}"
fi
fi
fi
I'm shure coderus would only need 300 bytes max. to achieve the same, but it does the job.
__________________
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: 87 | Thanked: 14 times | Joined on Jan 2012
#649
I have a problem since this morning. The billboard text box is blank after a while of having written something, all text is deleted and the screen shows nothing. What could be happening?. Thanks in advence.
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#650
is billboard settings show text?
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:39.