Examples for using root commands in Tasker on a Moto Milestone
Needed:
- Rooted milestone with Tasker and Locale Execute installed
- Knowledge on how to use lower variables in Tasker -> Here
- For testing: Any Terminal (Better Terminal Emulator Pro e.g.)
Basics
In the terminal use "su" for superuser access prior to the commands below.
Command for getting any values: "cat /sys/class/leds/lcd-backlight/brightness"
Command for writing values: "echo 100 > /sys/class/leds/lcd-backlight/brightness"
This is for testing purpose and should be done prior to usage in Tasker. (Just to go sure everything will work as intended)
In Tasker append an "@!" in front of all commands. E.g. "@! cat cat /sys/class/leds/lcd-backlight/brightness"
Fun with /sys/class
LCD backlight: /sys/class/leds/lcd-backlight/brightness
Values 0 and 1 will set the backlight OFF - you will not see a thing! Values between 2 and 20 are normally not allowed by Android (strongly dimmed!). Above 20 you can use Tasker's Set Brightness. The value for the brightness will be reset on the next display off (unfortunately - no workaround yet).
Keyboard backlight: /sys/class/leds/keyboard-backlight/brightness
Softkey backlight: /sys/class/leds/button-backlight/brightness
Values of 0 will switch it off, values between 1 and 255 will switch it on (but no dimming - 255 is the same brightness as 1). The value for the brightness will be reset on the next display off (unfortunately - no workaround yet).
Torch-Light (LED-Flash): /sys/class/leds/torch-flash/flash_light
Value 0 will switch it off. Between 1 and 255 you can set the brightness of the LEDs (255 is amazingly bright, really). Beware! Those LEDs are not designed for prolongued use!
Notification RGB LED red: /sys/class/leds/red/brightness
Notification RGB LED blue: /sys/class/leds/blue/brightness
Notification RGB LED green: /sys/class/leds/green/brightness
As before: 0 switches the appropriate color off, between 1 and 255 it is set to the appropriate value (although there is no HUGE difference in brightness between 1 and 255). The blue part of the LED is somewhat weak, so if you want some "white" Notification you will have to do some tweaking.
Overclocked devices
If you got an overclocked milestone you should already know:
/proc/overclock/max_rate for the CPU rate at max and the appropriate voltage in:
/proc/overclock/max_vsel
Busybox
If you have busybox installed (if you have root - you should also have an installed busybox) you can use some of it's commands, e.g.:
reboot: Reboots the phone (the same as switching it off and on again, but without PIN code)
Usage examples: Navigation in the night / Docking state
To be honest, I *hated* using the milestone as a navigation device at night. On the lowest screen brightness value the screen was still illuminating the whole car. Other people driving by could see my face and tell my mood without problems. Not anymore:
Context: App > CoPilot
Tasks:
Misc > GPS on
Plugin > Execute "@! echo 10 > /sys/class/leds/lcd-backlight/brightness"
Plugin > Execute "@! echo 0 > /sys/class/leds/button-backlight/brightness"
Click Done. Then click the Profile long and add another context:
Time > Between (e.g.) 21:00 and 06:00 the profile can be activated. (So the screen won't get dimmed on a sunny day at noon).
These values will only work until the next screen off, but that doesn't matter as the screen will stay on during my trip to somewhere.
In the meantime I use the same values when my stone is in the dock for charging. I don't switch it off anymore but use it as a very cool, stylish and *DIMMED* clock:
Context: State > Docked Desk
Tasks:
Display > Stay On With AC or USB Power
Plugin > Execute "@! echo 5 > /sys/class/leds/lcd-backlight/brightness"
Plugin > Execute "@! echo 0 > /sys/class/leds/button-backlight/brightness"
(besides some other stuff > WLAN off, Sync off, Silent Mode)
As before: Screen Off resets the values, but that doesn't matter.
Usage example: Widget with SU commands
I got a widget for the torch on my milestone:
Make a new Tasker wiget on the desktop and in Tasker:
Name: SU commands, Task Type: Menu
Plugin > Execute "@! echo 0 > /sys/class/leds/torch-flash/flash_light", Label: "Torch Off"
Plugin > Execute "@! echo 10 > /sys/class/leds/torch-flash/flash_light", Label: "Torch On"
Plugin > Execute "@! echo 255 > /sys/class/leds/torch-flash/flash_light", Label: "Torch Full"
Good workaround, as the torch does not work on the Moto milestone in the actual version of Tasker. :)
At last
There are A WHOLE LOT BUNCH of extras you could do with SU commands: Check the memory and battery information, (voltage for example) and use it to set an appropriate max_rate for your overclocking. Send the device to sleep (if you want to) or even reboot it. Copy/write/exchange files. Do any Linux commands (if busybox is installed). And so on and so on. Just mighty. ;)
IF YOU HAVE FOUND ANY ADDITIONAL VARIABLES OR OTHER STUFF PLEASE DO APPEND!!! :)
Best regards, payce.
+++Additions:
sendevent /dev/input/event4 5 0 0 pretend keyboard out, thereby locking to landscape. Default keyboard won't show up though. Maybe usefull for navigation or some games.
sendevent /dev/input/event4 5 0 1 pretend keyboard in
Obviously you can use misc > run shell now instead of the locale plugin or secure settings, which has even more options.