Rootbasic

How-To: Root (superuser) commands in Tasker

First of all: BIG Acknowledgements go to Michael Mauch making SU commands possible with his Plug-In "Locale Execute"! See his page for more info: Locale Execute manual

What is root?
If you don't know "root" or "superuser" please check your local Android forums for that topic. Root is more or less the same as "administrator" in Windows and allows a whole lot bunch of things. As long as you don't know the topic "root" very well I explicitly DO NOT recommend to use the stuff explained below.

DISCLAIMERS

  • Root allows you to change nearly everything on your phone. Including system-relevant files. So there is always the possibility that you will lock up or even brick your phone! ALL decriptions below may only be used, if you know the risk and accept it. Neither the author nor anyone else associated with Tasker will be responsible to any damage your phone might take!!!
  • Especially Pent (the developer of Tasker) WILL NOT give any support on "root" topics! Pent developed Tasker to be useable without root. So Tasker is NOT intended to be used together with root commands. If you run into problems, append them in this article (far below there is a "Questions" paragraph) and somebody MIGHT answer you.
  • ALL commands you will see on this page were tested on a Motorola Milestone running on Android 2.1. This means that your phone might behave in another way than a milestone. This includes name and path of system variables and their values.

Installation

  • If not done yet, root your phone according to the appropriate manuals on the net.
  • Install "Locale Execute" plug-in from the market
  • Recommended: To test certain values and the behaviour of your phone any Terminal app (such as Better Terminal Emulator Pro) is recommended.

Basic remarks before starting

  • Superuser App will ask for permission for *every single new command* you use in Locale Execute. No workaround.
  • Up to now *I think* only single-lined commands are possible. So if you want to run a number of commands I recommend doing that via calling up a script or similar.
  • For some example code snippets *on a Motorola Milestone* showing some possible variables to change/use, please check this article: Motorola Milestone Examples
  • Regarding the GUI of Locale Execute: In the actual version of Locale Execute there is no GUI at all. Don't try to push any of the menu buttons. It will likely force-close Locale Execute.

Direct writes on system variables

  • In Tasker open "Tasks" and make a new one (e.g. "SU Testing")
  • Category: Plugin Action: Execute
  • Give it a name on the label and push the edit button
  • Insert your command with a leading:
    • "@!" if you do not want to see the command as a Popup
    • "!" if you want to see a popup with the command carried out
  • Typically, you will want to use "echo xyz > /sample/sample/sample" commands to write the value xyz to the variable sample/sample/sample.

Example command: "@! echo 20 > /sys/class/leds/lcd-backlight/brightness" will switch the backlight of your lcd to the value 20.

Indirect reads on system variables

  • As before:
    • In Tasker open "Tasks" and make a new one (e.g. "SU Testing")
    • Category: Plugin Action: Execute
    • Give it a name on the label and push the edit button
  • Instead of an "echo" command now use the "cat" command and write the value to a file on your sdcard. As an example code:
    • "cat /sys/class/leds/lcd-backlight/brightness > /sdcard/tasker/temp.txt"
    • This command will write the value of the backlight brightness to the file temp.txt
  • New task: Variable > Variable Set: Name "%TEMP" To "1"
  • New task: File > Read Line: File "/sdcard/tasker/temp.txt", Line "%TEMP", To Var "%TEMP"

%TEMP will be the value of the system variable which was read by "cat". Instead of "Read line" also "Read paragraph" might be used. btw: You *always* have to specify a variable which tells "Read line" which line to read. Because of this %TEMP is always set to "1" prior to the "Read line" command.

If reading multi-line entries (like memory info or cpu info), %TEMP might be changed to the appropriate line number or multiple reads might be carried out.

Indirect writes on system variables

Now with the upper commands this should be clear:

  • Set the variable %TEMP to the appropriate value (e.g. via Variable > Set Variable)
  • Write the value to a file: File > Write File: File "sdcard/Tasker/temp.txt", Text "%TEMP"
  • New task: Plugin > Execute: Name it on label and use following command:
  • "@! cat sdcard/tasker/temp.txt > sys/class/leds/lcd-backlight/brightness"

This will set the LCD backlight brightness to the value which was stored in %TEMP

Example codes

Examples for the Motorola Milestone: Motorola Milestone Examples

Questions

If you got questions just append them here. !This is not a guarantee that anybody will answer! For questions on root and commands in Linux I heavily recommend using appropriate Android forums for your phone.

As always: BEST REGARDS, payce! :)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License