Tri-Color LED Notifications and Automated Fstrim with Email Output

Discussion in 'Tasker Guides / Examples / Ideas Forum' started by TomTcom, Mar 19, 2015.

  1. TomTcom

    TomTcom Member

    Joined:
    Mar 18, 2015
    Messages:
    124
    Likes Received:
    5
    This is a guide for a tri-color notification. This guide will show you how to make a notification LED flash green, red, and blue real fast as opposed to just one color.

    These are from my XDA signature. They use Tasker and other phone components.

    http://forum.xda-developers.com/showthread.php?p=48840378#post48840378


    Working better now, last issue to resolve is how to reset the LED for charging back to the correct state after the LED scripts and Tasker tasks are run.

    Please note this is for a Samsung Galaxy S3. I now have a Nexus 5 and the LED works differently so you may have to research on what works for your phone in terms of notification triggering. Root will be required.

    1. Make a file on your sdcard (name it whatever you want) called ledscript.sh.
    2. Copy this into the file and save it:
    #!/bin/bash
    while (true);
    do
    echo 1 > /sys/devices/virtual/sec/led/led_pattern
    sleep 0.1
    echo 5 > /sys/devices/virtual/sec/led/led_pattern
    sleep 0.1
    echo 6 > /sys/devices/virtual/sec/led/led_pattern
    sleep 0.1
    echo 0 > /sys/devices/virtual/sec/led/led_pattern
    done
    3. Create a profile for any notification you want to have the tri-color LED.
    4. Now create a task that runs a shell script.
    For Comand type this: . /sdcard/ledscript.sh (Please don't forget the period and space before the slash)
    Also check Use Root.
    5. Create another profile that will trigger a task to kill the script.
    ***Please note, I don't have service on this phone so I tested this with "Display On" > then run the script, then "Display Off" > kill the script. You may have to experiment.
    6. Now create a task again that runs a shell script.
    For Command type this: killall sh
    Also check Use Root.
    7. From your Profiles tab, tap your profile that is set up to kill the script.
    8. Long press on the associated task and select New Task.
    9. Make another shell script task with this command: echo 0 > /sys/devices/virtual/sec/led/led_pattern
    Also check Use Root.

    So to sum it up, when I turn off my display, I get the flashing lights. When I turn the display on the script gets killed and then a second task sets the LED state back to 0 which is OFF. I had to make it two tasks because the killing of the script and resetting back to 0 was not working in a singular task.

    ***Another thing I'm still working on is if you are charging and then the LED is set back to 0, I haven't figured out what triggers the charging LED. So you would have to unplug/replug to get it to show your charging LED.

    For the script, you can play with setting sleep values. I believe sleep value is in seconds so 0.1 seconds to whatever value you want.

    Also, colors can be manipulated but you may need to experiment and find out what values control which colors and so on.

    I credit the discovery of the commands to this XDA post. After some additional research there are other XDA posts that pretty much reference a very similar method of what we are doing here so I guess more people were interested in it as well.

    http://forum.xda-developers.com/show....php?t=1989664

    Have fun!

    PS - if you have a Nexus 5 and can figure out something similar please help me out! I know there are trigger events in /sys/class/leds/{color} but haven't yet figured out how to pass the values with the echo command. Still working on it.

    http://forum.xda-developers.com/showthread.php?t=2452543
    Tasker is a great automation tool for Android. There are many ways to do tasks and automation so this is simply my way. Feel free to modify for yourself in any way and comment.

    I'm using a T-Mobile Galaxy S3 running Anthem AOKP ROM with Android 4.2.2.

    DISCLAIMER: If you don't know what fstrim is or does please do not use this guide until you understand fully.

    DO NOT USE THIS WITH ANDROID 4.3. Why? Android 4.3 already includes an automated fstrim so you would be redundantly running this.

    Assumptions in this guide:

    1. You have ROOT.
    2. You have Tasker app from the Play Store.
    3. You have Secure Settings app from the Play Store.
    4. You have Hacker's Keyboard app from the Play Store. Why?? I have not found a way to simulate a "long press" to create the ability to "paste". As a result, I use this keyboard and the 5 row compact layout that allows Tasker to physically touch the Ctrl key and the V key for pasting.
    5. You are using the keyguard only, no PIN or Pattern. Tasker and Secure Settings allow this but you must select other options than Keyguard to make it work.
    5a. The above is striked out because I was not having the correct success unlocking the "swipe" to unlock. As a result, this guide so far has only worked with no keyguard at all but I'm sure it will work fine if you substitute PIN and Pattern using Secure Settings.
    6. You have fstrim utility.To check if you have fstrim, open a terminal app and type "busybox". Look for fstrim in the results. If you have it proceed, if not you will need a custom busybox or a ROM that has the utility built into it.The next set of steps will create the required task and then the profile to run the task. In the end, we will run fstrim on 3 partitions and email the output of the results to ourselves. I do this for a "Daily Dashboard" of sorts. You don't need to do the email portion if you don't want. You can always just run the task or create it as an app using Tasker functionality.

    1. Open your file manager and create a new file on the sdcard or the extsdcard. I will call my file in this guide "maintenance.log" and I will use the location of "/extSdCard/maintenance.log". You may choose whatever path and filename you wish.
    2. Tap on the TASKS tab at the top of the app.
    3. Tap the + and name it. I named mine Fstrim.
    4. Tap Fstrim task and click the +. Select Plugin > Secure Settings > tap Edit > Wake Device > Screen & Keyboard Lights On. Choose a value. 4 seconds is fine because once the screen is on, it defaults to the normal Android timeout value of the lockscreen before it goes black. (freely change as needed)
    5. Tap + and choose Plugin > Secure Settings > Keyguard > Off
    5a. See the above 5a. strikeout reason. Here is where you could substitute PIN and Pattern.
    6. Tap + and choose Script > Run Shell.In the Command box, type rm /extSdCard/maintenance.log (this is used to delete the log on each run so we only have the output of the last fstrim run. Use whatever directory you wish to store the log file in and whatever filename you wish to use.7. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).
    8. Tap + and choose Script > Run Shell > put these 4 commands in the Command field and tick the "Use Root" check box.date >> /extSdCard/maintenance.log
    fstrim -v /data >> /extSdCard/maintenance.log
    fstrim -v /system >> /extSdCard/maintenance.log
    fstrim -v /cache >> /extSdCard/maintenance.log9. Tap + and choose Display > System Lock
    10. Tap on the TASKS tab at the top of the app.
    11. Tap the + and name it. I named mine Maintenance Email.
    12. Tap Maintenance Email task and click the +. Select Plugin > Secure Settings > tap Edit > Wake Device > Screen & Keyboard Lights On. Choose a value. 4 seconds is fine because once the screen is on, it defaults to the normal Android timeout value of the lockscreen before it goes black.
    13. Tap + and choose Plugin > Secure Settings > Keyguard > Off.
    13a. Again, here you can choose PIN and Pattern instead of keyguard.
    14. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).
    15. Tap + and choose File > Read File > put the location and filename in the field. > In "To Var" type %filecontents. (You can choose any variable name you wish).
    16. Tap + and choose Misc > Set Clipboard > in the "Text field type %filecontents.
    17. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).
    18. Tap + and choose Net > Compose Email > put the recipient (yourself) and fill out Subject line.
    19. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).
    20. Tap + and choose Script > Run Shell > put these 3 commands in the Command field and tick the "Use Root" check box.input tap 90 1232
    input tap 320 1123
    input tap 664 10021. Tap + and choose Task > Wait > use the up arrow for 5 seconds. (this is built in padding in case of deep sleep issues).
    22. Tap on the PROFILES tab at the top of the app.
    23. Tap + and choose Time. You only need to set whatever time you want in both "From" and "To" in order to have the task run every 24 hours. You shouldn't need to set the time with minutes in between. For example, I run mine at 4:30 every morning so both "From" and "To" are set to 4:30. Change this accordingly if you feel you need to.
    24. Make sure your PROFILE is set to On.
    25. Make sure Tasker is running, long press the gear icon at the top left when the app is open. You will see a toast notification that says enabled and when you exit the app, the running icon will be at the top left in your status bar.
    26. Enjoy!
     
    RuggedHunter and joaomgcd like this.
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Thanks for sharing! :)
     
    TomTcom likes this.
  3. z3us

    z3us New Member

    Joined:
    Feb 6, 2015
    Messages:
    25
    Likes Received:
    1
    I can't get the led task to work with my Note 3
    Any help?
    Thanks

    [​IMG][​IMG][​IMG][​IMG]
     
  4. TomTcom

    TomTcom Member

    Joined:
    Mar 18, 2015
    Messages:
    124
    Likes Received:
    5
    Hi, I'm sorry the guide at the top specifies it is for an S3 only. Various models of phones even is they are still Samsung store led information in different locations. Perhaps sift through your file system and see if you can find it for the note 3.
     
: tasker, led, fstrim

Share This Page