keymapperorg / KeyMapper

An Android app that change what the buttons do on your devices!
http://docs.keymapper.club
GNU General Public License v3.0
1.14k stars 156 forks source link

Add action: executing shell command #661

Open garywill opened 3 years ago

garywill commented 3 years ago

Developer TODO (don't remove)


Hi developer(s), thank you for great KeyMapper!

It would be nice to run a shell command when I trigger by a key/button.


Also, I'm looking for a way to combine KeyMapper with https://github.com/renyuneyun/Easer . Easer can set a user-custom shell command as action, but it can't set a key/button as trigger.

https://github.com/renyuneyun/Easer/issues/376

sds100 commented 3 years ago

Hello! Does Easer allow you to create launcher shortcuts for actions? If so then maybe the App Shortcut action will work in Key Mapper.

garywill commented 3 years ago

Easer supports home screen widgets. Every widget has an label ( I believe that's this widget's id) Then you can set tapping a widget with an id as trigger event.

But that widgets seem different than launcher shortcut. They won't appear in Key Mapper's "App Shortcut" section.

sds100 commented 3 years ago

Oh okay. Can you trigger Easer actions with Intents? There is an action in Key Mapper to send an intent

garywill commented 3 years ago

Easer supports receiving broadcast as trigger event. I'm not sure if that is "intent" ( I don't know a lot about Android's intent).

This is Easer's screenshot Screenshot_20210509-194255_Easer

If it is "intent", could you give me some idea how to do ?

sds100 commented 3 years ago

Yeah, a broadcast is a way for an app to send an intent to another app. In that case you'll want to create an Intent action in Key Mapper and choose the "broadcast receiver" target. Set the Intent action in Easer (in your screenshot) to be the same as in Key Mapper.

victorbnl commented 3 years ago

I didn't understand the thing with Easer but being able to start shell commands with the gestures would be really useful

victorbnl commented 3 years ago

Here's a temporary workaround

  1. Install Termux
  2. Create a .bashrc with
    alias a="your command"
  3. Create the action "Open Termux" with a delay then of about 1000 to 1500 ms
  4. Create the action "Touch the screen" twice and first touch the a key of the keyboard, and then enter

If you want to run it as root it will be

alias a="su -c 'your command'"
sds100 commented 3 years ago

Yeah, that works. I'll still leave the shell command feature request open

victorbnl commented 3 years ago

Yes it would be really cool to be able to execute commands, I think that's the most important and basic thing to have in this kind of app. If you can execute commands you can literally do whatever you do even though it's not made in-app, like uninstalling an app, changing a parameter...