Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
BuglessPete
Old
(Last edited by BuglessPete; 23rd June 2010 at 06:04 AM.)
#1  
Senior Member - OP
Thanks Meter 873
Posts: 412
Join Date: Feb 2010

 
DONATE TO ME
Default [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.
 
neckface
Old
#2  
neckface's Avatar
Senior Member
Thanks Meter 11
Posts: 637
Join Date: Feb 2010
Quote:
Originally Posted by BuglessPete View Post
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
disabled
keycodes 107 211

service reboot /system/bin/shutdown -r
disabled
keycodes 107 114

service recovery /system/bin/shutdown -rr
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.
Genius. Expect a donation from me.
 
Gregalous
Old
#3  
Senior Member
Thanks Meter 2
Posts: 340
Join Date: Jan 2010
Location: The Colony, Texas
Bumping this cause it seems like it would be pretty useful...
 
vboyz103
Old
#4  
Senior Member
Thanks Meter 37
Posts: 543
Join Date: Apr 2006
Thanks Pete for the tutorial, so I see two keys assigned to a script, so is it a combo press or just a single press?
 
chumba8
Old
#5  
Senior Member
Thanks Meter 5
Posts: 371
Join Date: May 2008
Location: Seattle Wa
That is awesome Pete good work and keep it up!!!!!!!
dehelflix Old
#6  
Guest
Thanks Meter
Posts: n/a
glad i donated to this guy, hes a smart cookie. hopefully, you're close to having enough for an evo!
 
neckface
Old
#7  
neckface's Avatar
Senior Member
Thanks Meter 11
Posts: 637
Join Date: Feb 2010
Donated.

Confirmation number: 036688013H805551B
 
Decad3nce
Old
#8  
Decad3nce's Avatar
Retired Forum Moderator / Recognized Developer
Thanks Meter 2702
Posts: 2,049
Join Date: Feb 2010
Applied your 'how to' to an idea of launching any application(or intent) by hardkey press(Custom App Launching). Let me know what you think.

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Boot Animation Paradise for your Android Device

The default boot animations on any device, no matter whichmanufacturer, are generally pretty … more

Flash Custom ROM and Recovery to Samsung Galaxy S 4

After reading about Dan Rosenberg’s bootloader exploit for the Samsung Galaxy S 4,I … more

Windows-Based Multi-Tool for the Sony Xperia U

If you are a flashaholic and an owner of the Sony Xperia U, you may be interested in the … more

XDA University: Crafting Recovery-Flashable Packages

Those of us who use Linux on a day to day basis don’t think twice about sinking … more