I would like to change the the background color of a text or its font color to change by executing a Tasker Task.

I would like to change the the background color of a text or its font color to change by executing a Tasker Task. As I’m a noob on scripting, could anyone please help me in writing a small piece of script for this.

If possible, this maybe extended for panel or folder background color etc. Thank you in advance.

]]>

14 Commentsto I would like to change the the background color of a text or its font color to change by executing a Tasker Task.

  1. Anonymous says:

    < ![CDATA[

    1. give your item a name (long-tap > customize item > more > + > set a name)



    2. create the following script (below) and give it an appropriate name (e.g. SetItemColor)



    3. make sure to make the necessary changes to the script (myItemName, colors, …)



    4. In tasker, create a task that runs a Lightning Action.  Configuration: Run a script.  select your script



    SCRIPT >>>>>>>>



    // make sure to change myItemName to the item’s name


    var item = LL.getCurrentDesktop().getItemByName(‘myItemName’);


    if(item == null)


    {


      Android.makeNewToast(“error – could not find item”);


      return;


    }



    var editor = item.getProperties().edit();


    if(editor == null)


    {


      Android.makeNewToast(“error – could not obtain PropertyEditor”);


      return;


    }



    //item box (“i.box”).  use “f.box” if a folder


    var box = editor.getBox(“i.box”);


    if(box == null)


    {


      Android.makeNewToast(“error – could not get box”);


      return;


    }



    // set box content (“c”) (reference API: Box)


    // for normal & selected (“ns”) regions


    // ARGB color.  here: lime green


    box.setColor(“c”, “ns”, 0xff00ff00);



    // set label color (reference API: PropertySet)


    // ARGB color.  here: blue


    editor.setInteger(“s.labelFontColor”, 0xff0000ff);



    // property editor changes are done in bulk.  commit them here.


    editor.commit();


    < <<<< END SCRIPT



    API reference:



    Box


    http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/Box.html



    PropertySet


    http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/PropertySet.html

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Oh that’s great, Josh Horner​. Thank you. I’m super excited to try this. May come back if I’ve something more to ask. Thanks for the help! This maybe a starting point for me to learn something new!!

    ]]>

  3. Anonymous says:

    < ![CDATA[

    No problem! This is a simple example that can be greatly expanded upon. Things here are very static for simplicity sake. Also, errors are checked, so it shouldn’t crash. Let me know if you need more assistance.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Thank you. Just checked it and works fine as per my expectation. Now I hope I can set the colors by passing variables defined in tasker. So can you please help me with that piece of code? Suppose the item label font color is to be changed dynamically by defining a variable say “mycolor” in tasker… Also please mention where and how do I set this code. Thanks again.

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Passing multiple variables into a script could be a little tricky.  You might need to use JSON or similar structured format to make it easier….or maybe just some string splitting/parsing.



    Let’s keep it simple and pass in a single value from tasker.  In this example, we’ll set a tasker variable to a hex ARGB color, pass that into a LL script, then set a single color to that value.



    Within the Tasker task:


    1) Variable Set


    Name: %myColorVariable To 0xFFFF0000



    (create a local [lowercase] tasker variable named %myColorVariable and set it to a hex ARGB color [red])



    2) Lightning Action


    Configuration: MyScript



    (same as before, select lightning action > Run a script.  but this time, whenever you select the script “MyScript”, check the [x] Script data checkbox, then type in %myColorVariable into the textbox below.  This will pass the contents of %myColorVariable to your script).  Note, you could always just hardcode the hex value into this data block, but that would eliminate the purpose of the tasker variable….



    Within the script:


    add the lines:



    >>>>


    //get data passed into the script


    var param = LL.getEvent().getData();


    if(param == null)


    {


    Android.makeNewToast(“error – no data passed into the script”);


      return;


    }



    //then pick one of your colors from


    //before and replace the hex color


    //with “param”



    //here, we chose font color


    editor.setInteger(“s.labelFontColor”, param);

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Wow that’s great! I was doing some trial-and-error with making a tasker variable and trying to pass that to the script. Modified the task by adding a variable for new color.



    But I was not having any idea about the additional lines for passing the data to the script. Now since you’ve explained them neatly, I think I can venture into attempting without fear. Thanks for the explanation and efforts put in by you Josh Horner​. I’ll try this new set of information and let you know later.

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Josh Horner​​, I tried the above code, but could not succeed. The result appears like ‘param’ was not passed to the script. Did not receive any error though, but the color changed into some default one and not the expected %myColorVariable. Any idea where I might have made a mistake? (I suppose the first piece of code can be placed anywhere on the script).



    If you can look into this small issue, would be highly appreciated. Thanks again. 

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Sorry, I think it was a silly mistake. I declared the Variable as %myColorVariable (in caps?). When changed to %mycolor, I suppose it’s working fine. Let me play with this some more time and I will inform you the outcome. Sorry to bother you in the meantime.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    You can name the tasker variable whatever you want, but note the tasker scoping convention: if the first letter is lowercase, it is local to that task. If the first letter is uppercase, it is global to tasker

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Thank you for that. I’m improving my skills 🙂

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Thank you all. This has been a very usefull post for me.


    I made in Tasker a Zooper Widget colorpimper, I thought It would be cool to adjust the Lightning Launcher colors also with this.:


    http://youtu.be/GY7rR4GNP_c


    Now have to find how to pass multiple colors.

    ]]>

  12. Anonymous says:

    < ![CDATA[

    I’m also interested in knowing this. Here Josh Horner​ said that passing multiple variables can be done, but is little tricky. Let’s see whether he may explain this in an easy way, Wern-Yuen Tan​​…. 

    ]]>

  13. Anonymous says:

    < ![CDATA[

    I forgot to mention that it was very cool Evelien Wijbenga​

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Prasad Kaladi thank you.

    ]]>

Leave a Reply

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