Keyboard buttons -> run script

Post Reply
romanstyler
Posts: 20
Joined: Tue Oct 04, 2016 5:40 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Keyboard buttons -> run script

Unread post by romanstyler » Mon Oct 24, 2016 7:02 am

Hi guys, ODROID is really cool thing.
I like to use it with my TV and home automation.

But it would be really great feature to run some scripts by clicking on special hotkey on keyboard.
For example:
1) I have smart home server with HTTP API.
2) I just want to toggle celling lamp.
3) I want to click hotkey, or media button on keyboard to do it.

Let's summirize. Could you tell me, is it possible to:
1) Catch global keyboard event (no matter which screen or application).
2) Run script (bash for example).

P.S. I had some experience with Android Keyboard Helper: https://play.google.com/store/apps/deta ... lper&hl=ru
But it only allows to run application. In additional there is delay 1-4 seconds before action.

I will appreciate any idea, advice or link. Thank you.

User avatar
rooted
Posts: 7259
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 452 times
Been thanked: 127 times
Contact:

Re: Keyboard buttons -> run script

Unread post by rooted » Mon Oct 24, 2016 10:21 am

You could use evtest and a bit of bash.

romanstyler
Posts: 20
Joined: Tue Oct 04, 2016 5:40 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: Keyboard buttons -> run script

Unread post by romanstyler » Mon Oct 24, 2016 5:07 pm

Thank you very much!

If I'm not wrong this application (evtest), allows to handle all keyboard event.
Please correct me is it's possible.
I want to start trying this investigation. What do I need?

1. Install ssh daemon to ODROID.
2. Connect remotelly.
3. Add bash script which allows to listen to evtest application and do some actions needed for me.
4. Set up autorun of this script with OS.

User avatar
rooted
Posts: 7259
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 452 times
Been thanked: 127 times
Contact:

Re: Keyboard buttons -> run script

Unread post by rooted » Mon Oct 24, 2016 6:41 pm

Your method should work.

Create bash script which monitors output from evtest and reacts when desired key is pressed.

User avatar
mad_ady
Posts: 7347
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 350 times
Been thanked: 252 times
Contact:

Re: Keyboard buttons -> run script

Unread post by mad_ady » Wed Oct 26, 2016 1:45 am

If you're on android I don't think you can use evtest. You should look into Tasker instead

User avatar
rooted
Posts: 7259
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 452 times
Been thanked: 127 times
Contact:

Re: Keyboard buttons -> run script

Unread post by rooted » Wed Oct 26, 2016 1:47 am

mad_ady wrote:If you're on android I don't think you can use evtest. You should look into Tasker instead
Just checked and evtest is not included in Android.

User avatar
codewalker
Posts: 832
Joined: Mon Feb 25, 2013 11:03 am
languages_spoken: english
ODROIDs: all
Has thanked: 31 times
Been thanked: 39 times
Contact:

Re: Keyboard buttons -> run script

Unread post by codewalker » Wed Oct 26, 2016 3:44 pm

Here evtest binary for C2.
evtest.tar.gz
(5.87 KiB) Downloaded 89 times

Code: Select all

$ tar zxvf evtest.tar.gz
$ adb remount 
$ adb push evtest /system/bin/

romanstyler
Posts: 20
Joined: Tue Oct 04, 2016 5:40 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: Keyboard buttons -> run script

Unread post by romanstyler » Wed Oct 26, 2016 5:57 pm

Thank you guys!
I'm new with bash, so it will take time to figure out.
But found command called getevent
If returns all needed codes from connected devices.

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 3 guests