View Single 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