How to run a shell command?

This is the place to ask "How do I ...?"
Post Reply
Kaziq
Posts: 1
Joined: Mon Apr 08, 2019 11:34 am

How to run a shell command?

Post by Kaziq » Mon Apr 08, 2019 11:43 am

Hi, I want to turn off and lock the screen when I double-tap on an empty space.
I have found a way to turn off and lock by a shell command. It is: su -c "/system/bin/input keyevent 26"
It works fine with termux.
I have written to the LL's author, and he told me to write this script, and assign it to a double-tap action:

bindClass('java.lang.Runtime');
Runtime.getRuntime().exec('su -c "/system/bin/input keyevent 26"');

But it doesn't work. The screen is not turned off when I double-tap. The only reaction is a message that LL has been granted root privileges.
I tried to look this up in google, and it seems like a proper way of running shell commands from Java.\
What can I do to make it working?

User avatar
Pierrot
Site Admin
Posts: 181
Joined: Wed Jan 23, 2019 12:18 pm
Location: French Alps

Re: How to run a shell command?

Post by Pierrot » Wed Apr 10, 2019 5:47 am

If you get the message that LL has been granted root privileges, then it means that at least the first part of the command has been executed. Maybe try to replace "/system/bin/input keyevent 26" with something else that could help you check whether the privileged command is executed.

Post Reply