[Method] Automate the Theater Mode

Search This thread

qingtest

Senior Member
Mar 14, 2014
53
23
******************************
A late note:
below contents were written in May2015, after some days I paid my attention to other things (now Oct2015).
If you are new to read, and really interested to achieve this, you may also read the following comments, which may contain some new thoughts/ better methods.
Currently my new watch system is not rooted and am not so hungry on battery. But I promise I will be back to tidy through when I got spare time.
Thanks again for reading.
******************************

I got a way to automate the "Theater mode" of my watch.
I would like my wear to auto switch to "Theater mode" at night and exit every morning to save battery. (Just too lazy to remember to switch it when sleeping ). The real problems are ①google doesn't provide an API for developers ②currently no good method to execute native standalone command on watch.

My basic idea is to simulate a double tap on power button using shell. This would not be that difficult like ②..
Seems current apps don't provide such function: like autowear, weartasker,tasker for wear.... none of them provide a function of executing command on watch.
Then I used thread of gusano38 to apply a debugging of wear from phone (pretend as a PC).
Besides, there is another thread of joschi70 on wearshell, I don't know much about bean shell, so no idea whether it can modify wear setting rather than just retrieving info.

Here are the detailed steps:
Your phones should be rooted.

A. One time record
1. debug your watch (turn on in watch developer opition)
2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
4. There should be a "doubletap” located in you watch /sdcard
use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working

B. After you finish step A, you can always use the following code to trigger current Theater mode
allow bluetooth debugging
Code:
[COLOR="gray"]su
adb kill-server
export HOME=/sdcard
setprop service.adb.tcp.port 5555
stop adbd
start adbd
adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444
sleep 2
adb -s localhost:4444 shell "input keyevent 26; cat /sdcard/doubletap > /dev/input/event2"
setprop service.adb.tcp.port -1
stop adbd
start adbd
adb kill-server
exit[/COLOR]

Also recorded a short demo video

Note: NOT recommended for daily use, maybe you prefer a simple hardware tap, but here debugging mode may make your wear unsafe (therefore this is permanent notification)


=========================================================

:) It has been some time since my above post, I tried beanshell and finally solved my own problem.
The disadvantage of debug is unsafe, permanent notification, and delay(e.g. my above codes need wait 2s for adb service to be ready). No one if use wearshell.

main code
Code:
import java.lang.Runtime;
import java.io.DataOutputStream;
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("input keyevent 26;cat /sdcard/doubletap>/dev/input/event2;");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();

How:
Step B:
1. install wearshell
2. Prepare above main code, you can either
save to a file (e.g. doubletap.bsh) in /sdcard of watch, and call the through source("/sdcard/doubletap.bsh")
or
directly run (sometimes need to combine into one line like intent)
3. use intent to call: de.fun2code.android.wear.shell.EXEC with extra "bsh".

Now you are free to use it daily!

tumblr_nolv4xCknS1uvcr50o1_400.png



============================================================

:) This is a third update: I grayed the ADB part of first post for not confusing. This time I show how I used it.

Basically I make my watch into Theater mode and turn off Bluetooth of my phone at night. In the morning do the opposite things:
tumblr_noyth1HLDv1uvcr50o2_500.png

Just skip the run shell step which kills "bluetooh share" app (my phone has some problem with BT).

This is just one part pf my day/night switch tasks e.g. I also have auto airplane mode and interruption mode. By the way, I don't use airplane mode to turn off bluetooth. Simply because I want my watch to connect a little longer. To do that, you can set "airplane radios" so that you decide whether or not to turn off wifi/bluetooth/etc when you go to airplane mode.

This should save battery a little if not too much. Your decision if it helps you. ;)
my one day sample:
tumblr_noyth1HLDv1uvcr50o3_400.png
 
Last edited:

insaned

Senior Member
Aug 26, 2008
246
38
I was searching a solution for this.. However this is still not a daily solution! However this puts a few steps closer at least. Thanks

Sent from my SM-G920F using Tapatalk
 

letsgoflyers81

Senior Member
Jun 25, 2007
375
7
I have updated. wearshell worth to try.

This project looks great since it would let me automate activating theater mode with Tasker and I haven't found any other ways to do it. If I understand your post correctly, I need to save the code to a file and save on my watch's storage. How do I copy the file there?
 

insaned

Senior Member
Aug 26, 2008
246
38
I installed the wearshell , then placed the file with the code named doubletap.bsh in watch sdcard folder and created intent in tasker exactly like in the screenshot and nothing.. The intent goes as it should (green dot on tasker) but the watch still the same..

Sent from my SM-G920F using Tapatalk
 

qingtest

Senior Member
Mar 14, 2014
53
23
In tasker the target is Activity/Service, not BroadcastReceiver.
if this does not solve, can you just paste the codes to web shell page (can also insert 'echo xxx;'), see if there is any output or error?
If error maybe it is the root permission, as you can see my sample code needs su.
well I think the key simulation function may not necessarily need root, but I had my watch rooted (my default). You can either root watch or make a little change to the java codes (so that not requiring root permission).
 
Last edited:

insaned

Senior Member
Aug 26, 2008
246
38
In tasker the target is Activity/Service, not BroadcastReceiver.
if this does not solve, can you just paste the codes to web shell page (can also insert 'echo xxx;'), see if there is any output or error?
If error maybe it is the root permission, as you can see my sample code needs su.
well I think the key simulation function may not necessarily need root, but I had my watch rooted (my default). You can either root watch or make a little change to the java codes (so that not requiring root permission).

I was using target as activity.
The watch wakes up the screen like if o touched it in normal mode, but nothing else.


My watch it is supposed to be rooted.. I get the # when using shell, but when I saw on code that had SU it was my first though that it might not be rooted.
What changes you suggest for the code? I'm a bit dumb on code since I'm a basic self learner...

Sent from my SM-G920F using Tapatalk
 
Last edited:

qingtest

Senior Member
Mar 14, 2014
53
23
It should work. For problem shooting purpose I guest you check shell and beanshell separately.
1. Make sure adb works in the command window.
The first command "input" is to simulate power press, it should 100% work.
The second command "cat" is to simulate double press, if not working you need to redo the recording.
2. Run beanshell with any command like "echo aaa" in the webpage it should 100% work [edit: print("aaa");]
3. Run my code in webpage, should work
4. Put in tasker
Let me know which step you cannot go through.
 
Last edited:
  • Like
Reactions: insaned

insaned

Senior Member
Aug 26, 2008
246
38
It should work. For problem shooting purpose I guest you check shell and beanshell separately.
1. Make sure adb works in the command window.
The first command "input" is to simulate power press, it should 100% work.
The second command "cat" is to simulate double press, if not working you need to redo the recording.
2. Run beanshell with any command like "echo aaa" in the webpage it should 100% work
3. Run my code in webpage, should work
4. Put in tasker
Let me know which step you cannot go through.

I'm having problem right on the second command... using "adb shell cat /sdcard/doubletap>/dev/input/event2" returns in command prompt "The system cannot find the path specified"... however I have triple checked and I have the file doubletap.bsh in the SDCARD folder....
 

letsgoflyers81

Senior Member
Jun 25, 2007
375
7
I pushed the doubletap.bsh file to /sdcard and it's not working for me. Running a task with the intent doesn't do anything despite showing the green dot. My watch isn't rooted so I'm sure that's a factor. When I run the code on the web interface this is the error I get
BeanShell: error code bsh.TargetError: Sourced file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : Typed variable declaration : Method Invocation exec : at Line: 3 : in file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : .exec ( "su" )

Target exception: java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null

I tried removing what I thought was calling on su permissions but couldn't get it to work, but it may just be poor syntax. Do you know what the code would be if it's not using su?

Edit:

I can't even get the echo beanshell command to run. When I enter 'echo aaa' in the webpage I get the following:

BeanShell: error code bsh.EvalError: Sourced file: inline evaluation of: ``echo aaa ;'' : Typed variable declaration : Class: echo not found in namespace : at Line: 1 : in file: inline evaluation of: ``echo aaa ;'' : echo
 
Last edited:

qingtest

Senior Member
Mar 14, 2014
53
23
there are two files 1. doubletap 2. doubletap.bsh.
The first one includes is generated following my step A, did you check it?
 

qingtest

Senior Member
Mar 14, 2014
53
23
sorry "echo" is only for bash.. if you are running beanshell it should be print("aaa"); which work 100%
 

letsgoflyers81

Senior Member
Jun 25, 2007
375
7
there are two files 1. doubletap 2. doubletap.bsh.
The first one includes is generated following my step A, did you check it?

Thanks but I'm still overlooking something.

A. One time record
1. debug your watch (turn on in watch developer opition)
2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
4. There should be a "doubletap” located in you watch /sdcard
use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working

I need to do the above first even if I'm not using the run shell command, correct? I have my watch set to ADB debugging on, but where am I entering the commands? I'm sure I'm just not understanding what to do.
 

insaned

Senior Member
Aug 26, 2008
246
38
A. One time record
1. debug your watch (turn on in watch developer opition)
2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
4. There should be a "doubletap” located in you watch /sdcard
use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working

I assumed we could do B without A, so I guess this was the mistake.
Still I'm lacking some knowleage to where we do this and how..
Where we go for one time record and where we run all this steps? ADB to use the "getevent" and the command?
If you could ptovide some more baby steps would be helpfull! thanks

EDIT:eek:k, I guess I figured it out partially
WIth command prompt and watch screen ON run "adb shell getevent" and while running double press the button (to induce theater mode).
In my phone it showed up like this in the command prompt when I double pressed the button:
I don't get the "bcmpmu_on" on any event but rater "gpnp_pon"

could not open /dev/input/event0, Out of memory
add device 1: /dev/input/event10
name: "ssp_context"
add device 2: /dev/input/event9
name: "tilt_wake_sensor"
add device 3: /dev/input/event8
name: "hrm_lib_sensor"
add device 4: /dev/input/event7
name: "meta_event"
add device 5: /dev/input/event6
name: "step_cnt_sensor"
add device 6: /dev/input/event5
name: "uncal_gyro_sensor"
add device 7: /dev/input/event4
name: "sig_motion_sensor"
add device 8: /dev/input/event3
name: "uncal_geomagnetic_sensor"
add device 9: /dev/input/event2
name: "geomagnetic_sensor"
add device 10: /dev/input/event1
name: "qpnp_pon"
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000


NOw it's here I'm kind of stuck.. now Im trying to use in the command prompt :
adb shell sendevent cat /dev/input/event1 > /sdcard/doubletap

I event tried

adb shell su sendevent cat /dev/input/event1 > /sdcard/doubletap

and it's returning
"The system cannot find the specified path"

what I'm I missing?
 
Last edited:

letsgoflyers81

Senior Member
Jun 25, 2007
375
7
I assumed we could do B without A, so I guess this was the mistake.
Still I'm lacking some knowleage to where we do this and how..
Where we go for one time record and where we run all this steps? ADB to use the "getevent" and the command?
If you could ptovide some more baby steps would be helpfull! thanks

EDIT:eek:k, I guess I figured it out partially
WIth command prompt and watch screen ON run "adb shell getevent" and while running double press the button (to induce theater mode).
In my phone it showed up like this in the command prompt when I double pressed the button:
I don't get the "bcmpmu_on" on any event but rater "gpnp_pon"

could not open /dev/input/event0, Out of memory
add device 1: /dev/input/event10
name: "ssp_context"
add device 2: /dev/input/event9
name: "tilt_wake_sensor"
add device 3: /dev/input/event8
name: "hrm_lib_sensor"
add device 4: /dev/input/event7
name: "meta_event"
add device 5: /dev/input/event6
name: "step_cnt_sensor"
add device 6: /dev/input/event5
name: "uncal_gyro_sensor"
add device 7: /dev/input/event4
name: "sig_motion_sensor"
add device 8: /dev/input/event3
name: "uncal_geomagnetic_sensor"
add device 9: /dev/input/event2
name: "geomagnetic_sensor"
add device 10: /dev/input/event1
name: "qpnp_pon"
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000


NOw it's here I'm kind of stuck.. now Im trying to use in the command prompt :
adb shell sendevent cat /dev/input/event1 > /sdcard/doubletap

I event tried

adb shell su sendevent cat /dev/input/event1 > /sdcard/doubletap

and it's returning
"The system cannot find the specified path"

what I'm I missing?

I'm stuck at the same place you are. When I run "adb shell getevent" from the command prompt I get results that show "gpnp_pon" for event1 and there's no "bcmpmu_on". So I've tried "adb shell sendevent cat /dev/input/event1 > /sdcard/doubletap" and "adb cat /dev/input/event1 > /sdcard/doubletap" and both give me the same error, "The system cannot find the path specified."
 
  • Like
Reactions: insaned

qingtest

Senior Member
Mar 14, 2014
53
23
Hi I hoped to make it clear but was too lazy to wrote every detail where I assume readers were familiar with adb.
This is the answer for you two:
①You should know the basic idea is to simulate keypress.
The "input keyevent" does not have the ability to simulate a double tap, that's why we need to use adb to record.
The recorded data is put in the file "doubletap"
②From your question, I guess you are not so familiar with cmd right?
If you run "adb cat /dev/input/event1 > /sdcard/doubletap" in dos cmd, it will actually only run the command "cat /dev/input/event1 " and retrieve the result then write to a file "/sdcard/double" in windows. However, windows does not have such a path, that's why error is reported.
③ sorry I only have played with my own watch, I think the one ‘**on’ should be equivalent to my 'bcmpmu_on'.
④ To do it right, you need to quote the command like this: adb shell "cat /dev/input/event1 > /sdcard/doubletap"
Or first go into adb shell ,then run the command (like below picture)
tumblr_np1yx5eVGv1uvcr50o1_540.png

↑After double press, press Ctrl+C to stop. Then adb will exit with "^C"

The file should already in /sdcard/, can check like below: (in your case doubletap)
tumblr_np1ztkNShp1uvcr50o1_1280.png


Now you can simply run below command to test. should toggle theater mode 100%: (in your case doubletap)
tumblr_np1zvabwJV1uvcr50o1_1280.png
 
Last edited:
  • Like
Reactions: insaned

letsgoflyers81

Senior Member
Jun 25, 2007
375
7
Hi I hoped to make it clear but was too lazy to wrote every detail where I assume readers were familiar with adb.
This is the answer for you two:
①You should know the basic idea is to simulate keypress.
The "input keyevent" does not have the ability to simulate a double tap, that's why we need to use adb to record.
The recorded data is put in the file "doubletap"
②From your question, I guess you are not so familiar with cmd right?
If you run "adb cat /dev/input/event1 > /sdcard/doubletap" in dos cmd, it will actually only run the command "cat /dev/input/event1 " and retrieve the result then write to a file "/sdcard/double" in windows. However, windows does not have such a path, that's why error is reported.
③ sorry I only have played with my own watch, I think the one ‘**on’ should be equivalent to my 'bcmpmu_on'.
④ To do it right, you need to quote the command like this: adb shell "cat /dev/input/event1 > /sdcard/doubletap"
Or first go into adb shell ,then run the command (like below picture)
tumblr_np1yx5eVGv1uvcr50o1_540.png

↑After double press, press Ctrl+C to stop. Then adb will exit with "^C"

The file should already in /sdcard/, can check like below: (in your case doubletap)
tumblr_np1ztkNShp1uvcr50o1_1280.png


Now you can simply run below command to test. should toggle theater mode 100%: (in your case doubletap)
tumblr_np1zvabwJV1uvcr50o1_1280.png

I'm familiar with command prompt and know the basics with adb. I guess it was confusing that some of the steps were very detailed so I could do exactly what you wrote, but some steps were missing things and I didn't realize it. Thank you for your patience.

After doing what was in your last post I'm able to toggle theater mode from adb on my laptop while my laptop is connected, so that's great. However doing it from the Wearshell intent still doesn't work. I copied the code you posted and changed event2 to event1, but I'm pretty sure the problem is that your code uses su and my watch is not rooted. Do you know what the code would look like without using root?

This is the error I got from Wearshell

BeanShell: error code bsh.TargetError: Sourced file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : Typed variable declaration : Method Invocation exec : at Line: 3 : in file: inline evaluation of: ``import java.lang.Runtime; import java.io.DataOutputStream; Process su = Runtime. . . . '' : .exec ( "su" )

Target exception: java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null
 
Last edited:

qingtest

Senior Member
Mar 14, 2014
53
23
I just updated my watch to 5.1.1, so lost root. The code is no longer working for me either. I confirm the input and cat do not necessarily need su permission.
However, I don't have an existing code for you ( i am relative new in beanshell too). Will try and share with my spare time (you are welcome to do so too ;))
 
  • Like
Reactions: insaned

insaned

Senior Member
Aug 26, 2008
246
38
Thanks a million for the patience to the detailed adb explanation which helped a lot!
Already working both in Adb, Wearshell and tasker intent. I have the Watch rooted..

However I DID a slight change to the code, I had to remove the " input keyevent 26" from the line, because it was causing only the screen to turn on and without it works great. The double tap on the button for theater mode doesn't need screen on anyway, so I gave it a shot to remove and it worked.

import java.lang.Runtime;
import java.io.DataOutputStream;
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("cat /sdcard/doubletap>/dev/input/event1;");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.waitFor();
 

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    ******************************
    A late note:
    below contents were written in May2015, after some days I paid my attention to other things (now Oct2015).
    If you are new to read, and really interested to achieve this, you may also read the following comments, which may contain some new thoughts/ better methods.
    Currently my new watch system is not rooted and am not so hungry on battery. But I promise I will be back to tidy through when I got spare time.
    Thanks again for reading.
    ******************************

    I got a way to automate the "Theater mode" of my watch.
    I would like my wear to auto switch to "Theater mode" at night and exit every morning to save battery. (Just too lazy to remember to switch it when sleeping ). The real problems are ①google doesn't provide an API for developers ②currently no good method to execute native standalone command on watch.

    My basic idea is to simulate a double tap on power button using shell. This would not be that difficult like ②..
    Seems current apps don't provide such function: like autowear, weartasker,tasker for wear.... none of them provide a function of executing command on watch.
    Then I used thread of gusano38 to apply a debugging of wear from phone (pretend as a PC).
    Besides, there is another thread of joschi70 on wearshell, I don't know much about bean shell, so no idea whether it can modify wear setting rather than just retrieving info.

    Here are the detailed steps:
    Your phones should be rooted.

    A. One time record
    1. debug your watch (turn on in watch developer opition)
    2. use "getevent" to find "bcmpmu_on" related event, in my case, event2
    3. run command "cat /dev/input/event2 > /sdcard/doubletap", double tap your power button, then use control-C to stop the command
    4. There should be a "doubletap” located in you watch /sdcard
    use "cat /sdcard/doubletap > /dev/input/event2" to run and test if it is working

    B. After you finish step A, you can always use the following code to trigger current Theater mode
    allow bluetooth debugging
    Code:
    [COLOR="gray"]su
    adb kill-server
    export HOME=/sdcard
    setprop service.adb.tcp.port 5555
    stop adbd
    start adbd
    adb forward tcp:4444 localabstract:/adb-hub
    adb connect localhost:4444
    sleep 2
    adb -s localhost:4444 shell "input keyevent 26; cat /sdcard/doubletap > /dev/input/event2"
    setprop service.adb.tcp.port -1
    stop adbd
    start adbd
    adb kill-server
    exit[/COLOR]

    Also recorded a short demo video

    Note: NOT recommended for daily use, maybe you prefer a simple hardware tap, but here debugging mode may make your wear unsafe (therefore this is permanent notification)


    =========================================================

    :) It has been some time since my above post, I tried beanshell and finally solved my own problem.
    The disadvantage of debug is unsafe, permanent notification, and delay(e.g. my above codes need wait 2s for adb service to be ready). No one if use wearshell.

    main code
    Code:
    import java.lang.Runtime;
    import java.io.DataOutputStream;
    Process su = Runtime.getRuntime().exec("su");
    DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
    outputStream.writeBytes("input keyevent 26;cat /sdcard/doubletap>/dev/input/event2;");
    outputStream.flush();
    outputStream.writeBytes("exit\n");
    outputStream.flush();
    su.waitFor();

    How:
    Step B:
    1. install wearshell
    2. Prepare above main code, you can either
    save to a file (e.g. doubletap.bsh) in /sdcard of watch, and call the through source("/sdcard/doubletap.bsh")
    or
    directly run (sometimes need to combine into one line like intent)
    3. use intent to call: de.fun2code.android.wear.shell.EXEC with extra "bsh".

    Now you are free to use it daily!

    tumblr_nolv4xCknS1uvcr50o1_400.png



    ============================================================

    :) This is a third update: I grayed the ADB part of first post for not confusing. This time I show how I used it.

    Basically I make my watch into Theater mode and turn off Bluetooth of my phone at night. In the morning do the opposite things:
    tumblr_noyth1HLDv1uvcr50o2_500.png

    Just skip the run shell step which kills "bluetooh share" app (my phone has some problem with BT).

    This is just one part pf my day/night switch tasks e.g. I also have auto airplane mode and interruption mode. By the way, I don't use airplane mode to turn off bluetooth. Simply because I want my watch to connect a little longer. To do that, you can set "airplane radios" so that you decide whether or not to turn off wifi/bluetooth/etc when you go to airplane mode.

    This should save battery a little if not too much. Your decision if it helps you. ;)
    my one day sample:
    tumblr_noyth1HLDv1uvcr50o3_400.png
    3
    I wanted to share an easy tasker WearShell recipe with you guys. I have two Tasker tasks, one is to turn theater mode on, the other is to turn it off.

    In the task, add a Send Intent action with these parameters:

    On:
    Action: de.fun2code.android.wear.shell.EXEC
    Extra: bsh: Runtime.getRuntime().exec("su -c settings put global theater_mode_on 1");

    Off:
    Action: de.fun2code.android.wear.shell.EXEC
    Extra: bsh: Runtime.getRuntime().exec("su -c settings put global theater_mode_on 0");

    Off will turn off theater mode, however still leave the watch screen off, however the screen will come back on with the next tap and theater mode will be off.
    1
    I have updated. wearshell worth to try.
    1
    It should work. For problem shooting purpose I guest you check shell and beanshell separately.
    1. Make sure adb works in the command window.
    The first command "input" is to simulate power press, it should 100% work.
    The second command "cat" is to simulate double press, if not working you need to redo the recording.
    2. Run beanshell with any command like "echo aaa" in the webpage it should 100% work [edit: print("aaa");]
    3. Run my code in webpage, should work
    4. Put in tasker
    Let me know which step you cannot go through.
    1
    Modified post of ShadowEO by pablo71 for brightness
    I wanted to share an easy tasker WearShell recipe with you guys for brightness

    In the task, add a Send Intent action with these parameters: for FULL BRIGHTNESS setting 5 (the number 254 in following tasker intent sets it)

    Action: de.fun2code.android.wear.shell.EXEC
    Extra: bsh: Runtime.getRuntime().exec("su -c settings put system screen_brightness 254 ");

    Brightness Setting 4 = 204
    Brightness Setting 3 = 153
    Brightness Setting 2 = 128
    Brightness Setting 1 = 106

    Lower Settings are possible, which is why the app Swapp True Dark is so good, BUT DON'T SET BRIGHTNESS SO LOW YOU CAN'T USE YOUR WATCH

    I set my brightness with an autovoice command filter creatively titled "brightness," so my intent looks this:

    Action: de.fun2code.android.wear.shell.EXEC
    Extra: bsh: Runtime.getRuntime().exec("su -c settings put system screen_brightness %avcommnofilter ");
    I found a totally other solution for setting watch to screen off during the night.
    I use tasker and autowear:
    create a profile with autowear commandevent &powerconnected& starting a task with autowear single screen. text color black, backgrnd color black, timeout (in advanced) 36000.
    create a second profile with autowear commandevent &powerdisconnected& starting a task with autowear app (launch system app Watch Face).

    thats it.
    if you connect your watch to power, the 1st profile open a black screen at the watch. this black screen will stay for 36000sec (10h)
    if you disconnect the watch, the 2nd profile set the watchface back to screen and voila !

    good luck and enjoy