KeyMapper icon indicating copy to clipboard operation
KeyMapper copied to clipboard

Add action: executing shell command

Open garywill opened this issue 3 years ago • 9 comments

Developer TODO (don't remove)

  • [ ] create new branch. put issue number at start of name
  • [ ] write tests before working on feature. put issue number in comment
  • [ ] update documentation
  • [ ] squash and merge
  • [ ] delete branch

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

garywill avatar May 06 '21 09:05 garywill

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

sds100 avatar May 08 '21 19:05 sds100

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.

garywill avatar May 09 '21 00:05 garywill

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

sds100 avatar May 09 '21 08:05 sds100

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 ?

garywill avatar May 09 '21 11:05 garywill

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.

sds100 avatar May 09 '21 11:05 sds100

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

victorbnl avatar Jun 26 '21 12:06 victorbnl

Here's a temporary workaround

  1. Install Termux
  2. Create a .bashrc with
alias a="your command"
  1. Create the action "Open Termux" with a delay then of about 1000 to 1500 ms
  2. 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'"

victorbnl avatar Jun 26 '21 14:06 victorbnl

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

sds100 avatar Jun 26 '21 15:06 sds100

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...

victorbnl avatar Jun 26 '21 15:06 victorbnl