Page 1 of 1

How to run a shell command?

Posted: Mon Apr 08, 2019 11:43 am
by Kaziq
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?

Re: How to run a shell command?

Posted: Wed Apr 10, 2019 5:47 am
by Pierrot
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.