[How To] Make Script Run By Using Hardware Keys
Ok, so it didn't take long before my little trick was found in my Droid ROM so I guess it's time to explain myself and share it here for the Evo.
I came up with a way to use the hardware keys to make services (a.k.a. scripts) run. It was rumored that these options were already built into Froyo and/or used in Cyanogen Mod, neither being true. This is just one of those ideas I wake up with in my head. After playing with it a few minutes it worked flawlessly.
To add these options to your boot.img add the following lines to your preferred init script inside the ramdisk before compiling.
#shutdown options by pete
service poweroff /system/bin/shutdown
oneshot
disabled
keycodes 107 211
service reboot /system/bin/shutdown -r
oneshot
disabled
keycodes 107 114
service recovery /system/bin/shutdown -rr
oneshot
disabled
keycodes 107 115
Obviously you can make these do different things other than shutdown. You can even choose different keys to make them run (hint: those keycodes are for droid).
As always please be respectful and atleast put idea by Pete or some sort of credit to make me feel happy if you use it.
|