![]() |
2013-02-18
, 17:12
|
Posts: 277 |
Thanked: 319 times |
Joined on Jan 2010
|
#642
|
![]() |
2013-02-18
, 17:14
|
|
Community Council |
Posts: 664 |
Thanked: 1,648 times |
Joined on Apr 2012
@ Hamburg
|
#643
|
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.
#!/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
![]() |
2013-02-18
, 17:22
|
|
Posts: 6,436 |
Thanked: 12,701 times |
Joined on Nov 2011
@ Ängelholm, Sweden
|
#644
|
#!/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 "}}"
![]() |
2013-02-18
, 18:46
|
|
Community Council |
Posts: 664 |
Thanked: 1,648 times |
Joined on Apr 2012
@ Hamburg
|
#645
|
![]() |
2013-02-18
, 19:07
|
|
Posts: 6,436 |
Thanked: 12,701 times |
Joined on Nov 2011
@ Ängelholm, Sweden
|
#646
|
if [ $percent -eq -1 ]; then echo -n "flight mode"; exit; fi
The Following User Says Thank You to coderus For This Useful Post: | ||
![]() |
2013-02-18
, 19:12
|
Posts: 277 |
Thanked: 319 times |
Joined on Jan 2010
|
#647
|
The Following User Says Thank You to slarti For This Useful Post: | ||
![]() |
2013-02-18
, 20:09
|
|
Community Council |
Posts: 664 |
Thanked: 1,648 times |
Joined on Apr 2012
@ Hamburg
|
#648
|
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.
#!/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
![]() |
2013-02-20
, 02:28
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#649
|
![]() |
2013-02-20
, 05:38
|
|
Posts: 6,436 |
Thanked: 12,701 times |
Joined on Nov 2011
@ Ängelholm, Sweden
|
#650
|
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