Pierre Hébert​​ I’m working on a script that uses desktop position to change the background color of a shortcut.

Pierre Hébert​​ I’m working on a script that uses desktop position to change the background color of a shortcut. The script works if I manually run the code from the Lightning menu or use the “Resumed” event. But I just can’t seem to make it run on the “Position Changed” event. Am I not using the event properly?

Here is the script if it helps:

var e = LL.getEvent();

var c = e.getContainer();

var wide = c.getWidth();

var xloc = c.getPositionX();

var scuthome= LL.getItemById(6750221).getProperties().edit();

if (xloc < 1080) {

scuthome.getBox(“i.box”).setColor(“c”,”ns”,0x1d000000);

scuthome.commit();

} else {

scuthome.getBox(“i.box”).setColor(“c”,”ns”,0x00000000);

scuthome.commit();

}

var scutcal= LL.getItemById(6750222).getProperties().edit();

if (1080 >= xloc && xloc << 2160) {

scutcal.getBox(“i.box”).setColor(“c”,”ns”,0x1d000000);

scutcal.commit();

} else {

scutcal.getBox(“i.box”).setColor(“c”,”ns”,0x00000000);

scutcal.commit();

}

]]>

20 Commentsto Pierre Hébert​​ I’m working on a script that uses desktop position to change the background color of a shortcut.

  1. Anonymous says:

    < ![CDATA[

    None that I am aware of, but that doesn’t mean there is no bug. If you add “alert(xloc);” just after the line “var xloc = c.getPositionX();”, does it display a correct value ?

    ]]>

  2. Anonymous says:

    < ![CDATA[

    It displays the correct value.



    it doesn’t seem to be running the script when I move around the desktop. Like I said, I can manually run the script and it performs just as expected.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    (This shouldn’t be the issue, but you wrote < < instead of <= )

    ]]>

  4. Anonymous says:

    < ![CDATA[

    🙂 I just noticed that myself. Already made the change. Thanks

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Maybe this is a dumb question, but are you sure you configured the right event ?


    I tried it right now and everything seems ok.


    Just in case, try to set a very short script such as “alert(LL.getEvent().getContainer().getPositionX());” to see if this one liner works.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    That didn’t work on mine. I copied this line exactly and set it to run on Position Changed.

    ]]>

  7. Anonymous says:

    < ![CDATA[

    And if you set any other action, such as “All apps” ? If it does not launch the app drawer, then I think that there is some mismatch of what you scroll and what you configure

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Other actions seem to work. I just tested the “Expand Notifications Tray” and it opened up as soon as I moved the desktop.



    But if that action works, how come a script won’t run? Even the simple one-liner you had me test.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    I am puzzled 🙁 Except if scripts are disabled in the general settings, but in this case no script would run so I assume this is not the case. Would it be possible for you to export a backup of your setup and send it to me ?

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Absolutely. What is the best way to send it?

    ]]>

  11. Anonymous says:

    < ![CDATA[

    by email at pierrox@pierrox.net(long tap on the archive in the backup/restore screen and you will get a “send” option)

    ]]>

  12. Anonymous says:

    < ![CDATA[

    It should be on its way. My network signal is somewhat poor right now so I don’t know how long it will take. I’m also going to aplologize now in case I accidentally bombarded your inbox

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Thanks I got it. There’s a bug, but not where it was supposed to be. Surprisingly it has been there since a long time ago. Fortunately there is a workaround until the fix in the next update: when selecting the script ,hit back when you see the popup to enter script data instead of tapping on the ok button, and it will work.

    ]]>

  14. Anonymous says:

    < ![CDATA[

    What was exactly the bug? If I could ask

    ]]>

  15. Anonymous says:

    < ![CDATA[

    That did it. That was driving me crazy. You’re easily one of the most helpful developers on here. Thanks so much

    ]]>

  16. Anonymous says:

    < ![CDATA[

    So that made it work and I found that that script was a little heavy and made moving between positions very laggy. So I have a new idea but have to pester Pierre Hébert​ and TrianguloY​ for one more question. Is there a way to call one script from another script?

    ]]>

  17. Anonymous says:

    < ![CDATA[

    TrianguloY this is related with the issue you reported earlier: the data is set to an empty string instead of null and in this case the position change event was not expecting a data here.



    Previously, scripts had no data and to maintain backward compatibility with existing setups the run script action encode everything in a string “id/script_data” or “id” if no script_data.

    ]]>

  18. Anonymous says:

    < ![CDATA[

    I’m assuming its a little more complicated than LL.runScript(script name) because I’m getting a “Can’t find method” error.

    ]]>

  19. Anonymous says:

    < ![CDATA[

    You need to pass data. You can simply use null if I remember correctly


    LL.runScript(“name”,null);

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *