yashsingh1/xdaforums huggingface dataset:
[Wear OS Software and Hacking General] pablo71:
is there a way to activate wearshell scripts from WITHIN the watch itself? .. I ask because I have sideloaded a tasker apk to my watch that recognizes wrist gestures and I was hoping there were some shell commands (or something) I could include in my tasker apk to send to wearshell to activate the stt script with a wrist gesture .. thanks joschi
[Wear OS Software and Hacking General] joschi70:
Currently that is not possible. I'll put that on my list of suggestions.
[Wear OS Software and Hacking General] aseeme555076:
wifioff(), wifion(); and light(); is work on Sony SWR50:)

But both wifioff.bsh and wifion.bsh is written with . . .

wifi.setWifiEnabled(false);
[Wear OS Software and Hacking General] joschi70:
Oops ... thanks for the info!

Has been corrected.
[Wear OS Software and Hacking General] pablo71:
I love this app so frikkin much ...

I'm now 4 months into smartwatch ownership and I can safely say that without Wearshell I personally wouldn't have use for a smartwatch, but after week 3 Wearshell quickly transformed my not-so-smartwatch into a genuinely useful tool that makes my jobs a lot easier ... so in week 4 I bought a second identical huawei watch to keep in my pocket in case I drain the battery on my main watch during work..

you did such a good job on this app Joschi .. Wearshell doesn't need to evolve into having a tasker plugin component to function brilliantly, but if it ever does I'll be your first customer, even though Wearshell operates flawlessly as is.

thanks again
[Wear OS Software and Hacking General] joschi70:
Thanks for the post ... glad that the app is working well for you.
[Wear OS Software and Hacking General] pablo71:
deleted post - asked question with no solution
[Wear OS Software and Hacking General] noraef:
Would there be a way to sort of wake Wear so the watch keeps ambient without ever turning the screen off?

I've been slightly handicapped since a stroke, and though I can use my left hand, the kind of exaggerated arm gestures that wake Wear out of ambient tends on being painful, and I mostly avoid moving that arm too much...

So every 10 minutes, the watch screen shuts off, which forces me to do the exaggerated arm gesture I avoid in the first place (or use the button, which I don't like either, as having to use two hands to watch the time isn't much better than having troubles to use only one).

Hence why I'm trying to find a way to keep the ambient mode with screen actually always on. Any idea?
[Wear OS Software and Hacking General] pablo71:
this would require rooted watch, and it's not best idea, but it would work. set up a profile in tasker that when (1) the Bluetooth name of your watch is connected and (2) the self-created variable named %WATCHCONNECTED is "0" it runs a task that first sets %WATCHCONNECTED to "1" then runs a loop where every 9 minutes an intent is sent to wearshell to stimulate pressing the watch's power button. this task action would be System > Send Intent > Action: de.fun2code.android.wear.shell.EXEC > Extra: bsh: exec("su -c keyevent 3;"); .... then set up a profile where if (1) the Bluetooth name of your watch is NOT connected and (2) the variable %WATCHCONNECTED is "1" then it runs a task that sets %WATCHCONNECTED to "0" and kills the task that runs the loop.

I have a profile 99% similar to this that prevents Google's Text To Speech Engine from going to sleep on my watch
[Wear OS Software and Hacking General] noraef:
[MENTION=942616]pablo71[/MENTION] Thanks! I ended up doing something similar with AutoWear (keep screen on, wait 1s, don't keep screen on). Does the same things as simulating a button press, but doesn't require root (though my watch is rooted).

Seems to be a strange bug with the Huwatch, as I've seen references to it on Negalite's ROM thread (tells about fixing patches, but still happens): it actually only happens after taking the watch off charger. If I reboot it after taking it off charger, it ends up taking many hours for the screen to turn off (which I still find annoying)...

Android Wear and its level of finish not even worthy of beta status, I guess (love the concept, hard not to hate the botched implementation). No wonder most big manufacturers won't release new watches this year...
[Wear OS Software and Hacking General] JimSmith94:
I see that you added Wifi on and off, would it be possible to add Airplane mode on and off?
[Wear OS Software and Hacking General] pablo71:
you could try this:

in tasker make a Send Intent action with:

ACTION: de.fun2code.android.wear.shell.EXEC

EXTRA: bsh: exec("su -c settings put system airplane_mode_on 1;");

where 1 or 0 turns it on or off

or is it ... put systems global

or is it ... airplane_mode_off and airplane_mode_on

well, there might be a variation of the above stuff that works good luck
[Wear OS Software and Hacking General] darkamikaze:
Think you can share that D: ? I think I'm running into that issue where after awhile tts won't start and I'd have to try it a couple times before tts comes back again.

Really digging what you've done here OP btw fantastic work!
[Wear OS Software and Hacking General] pablo71:
happy to share... import this project and try it out. you'll have to delete the names of my watches from the BT connected profile and the BT NOT connected profile and insert/search for your watch's Bluetooth name. this project sends a flurry of a dummy character to Google's tts engine when watch connects to wake it up and every 9 mins it sends another dummy character to tts to keep it awake. tts won't speak this dummy character of course, it just keeps it awake. this project also closes and reopens wearshell on the phone on every re-connection because on my setup I do get instances where wearshell will go to sleep if I walk too far away from my phone and there is a short loss of connection.

hopefully placing this tts keepalive project into your taskers project folder will do the job after you've traded my watches Bluetooth names for yours good luck
[Wear OS Software and Hacking General] Sideburnt:
Is there a command that would reboot the android wear device?
[Wear OS Software and Hacking General] joschi70:
I don't have a rooted watch, but on a rooted device this might work:

exec("su -c reboot now");
[Wear OS Software and Hacking General] wmtype:
hey together,

i am so glad that i found this fine tool :)

That expands all the possibility really wide. I managed to implement the most with the guides on this pages. Thanks to all!! Of course the most to the dev! :good:

One thing i am currently struggeling is how to play media on the watch. How can i use the mediaplayer object with an broadcast (from tasker for example)?

the doc says:

Usage

m e d i a p l a y e r ( )

BeanShell Example

I would like to send a broadcast to wearshell on the watch with a path (thewatch/sdcard/mysound.mp3). Since that are mostly short notification sound i don't think to need something like a abort method.

Can someone help me out?? Thanks!!!
[Wear OS Software and Hacking General] pablo71:
I could sure use some help: anyone know the beanshell code to simulate longpress of volume up and down keys? ... or maybe better would be Alt + Shift + z keycombo

I almost have fast spoken Google search results on watch by sideloading Google Talkback 4.3.0 - you can pause and resume Talkback by longpress volume up and down keys, but adb shell commands don't do it. bsh: exec("su -c input keyevent --longpress 25"); should work, but it just acts as a volume key click and brings up the volume slider, and I've searched for how to simulate Alt + Shift + z in javacode but still no luck. this is as far as I've come so far, but I just get errors:

import android.view.KeyEvent;

dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_VOLUME_UP));

SystemClock.sleep(1000);

dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_UP, KeyEvent.KEYCODE_VOLUME_UP));

Google Talkback instantly speaks the search results on the watch perfectly through the speaker via internal tts, but it turns the watch into a constantly talking nightmare - wearshell could provide a pause/resume feature activated when a voice search happens.

any help appreciated

EDIT: I think the Huawei Watch hardware requires additional keyboard drivers to be added in order to accept low level key events using sendevent key injection or java code, because ‘input keyevent' happens at framework level above what's needed, and all that's beyond my skill level. I'm halfway thru my fun project using Wearshell to inject touch events using the following intent to simulate a touch tap at coordinates 30x and 35y, then wait 1 second then tap 200x 180y

ACTION: de.fun2code.android.wear.shell.EXEC

EXTRA: bsh: exec("su -c sendevent /dev/input/event0 0003 0057 00000011;su -c sendevent /dev/input/event0 0003 0053 00000030;su -c sendevent /dev/input/event0 0003 0054 00000035;su -c sendevent /dev/input/event0 0003 0048 00000006;su -c sendevent /dev/input/event0 0003 0049 00000005;su -c sendevent /dev/input/event0 0000 0000 00000000;su -c sendevent /dev/input/event0 0003 0057 4294967295;su -c sendevent /dev/input/event0 0000 0000 00000000; su -c sendevent /dev/input/event0 3 57 -1;su -c sendevent /dev/input/event0 0000 0000 00000000; su -c sleep 1; su -c sendevent /dev/input/event0 0003 0057 00000000;su -c sendevent /dev/input/event0 0003 0053 00000200;su -c sendevent /dev/input/event0 0003 0054 00000180;su -c sendevent /dev/input/event0 0003 0048 00000001;su -c sendevent /dev/input/event0 0003 0049 00000001;su -c sendevent /dev/input/event0 0000 0000 00000000;su -c sendevent /dev/input/event0 0003 0057 4294967295;su -c sendevent /dev/input/event0 0000 0000 00000000; exit");

UPDATE: I think I've completed this project thanks to Wearshell. I'll post tasks and instructions in a couple days if it still works as awesome as it has been today.
[Wear OS Software and Hacking General] ertioct:
Hi mates,

I have tried to figure out how to get an answer back when I use stt.bsh from Tasker but I have not find the solution. So, I have made a tricky modification to stt in order to get the recognised text back to the phone (in form of file).

It is useful to receive the recognised text from the android wear device back to Tasker. It has allowed me to run any task I have in my phone without Autotasker. Just by doing this:

- First I modified a WatchFace in Watchmaker that executes a task1 into Tasker (by pressing some area in watch screen).

- That task1 asks me which task I want to execute, and does the same as stt (launching a google text recognising screen).

- After a couple of seconds, the text is send as a file which is on the phone's sdcard with my answer.

- Finally, task1 keeps running till it reads the text in the file, and it checks and executes the task I ordered.

I know it is a bit tricky and tedious, but this method does the trick . With tasker it takes no major effort to develop.

Hope somebody can help me to establish a Tasker variable from Beanshell or gives me directions on how to read the stdout from the Beanshell into tasker.

Here I leave you the link:

View attachment 4004907

Thanks to the developer for its awesome and versatile solution and to you in advance for the help!
[Wear OS Software and Hacking General] pablo71:
cool solution! I've attached the way to do it through tasker to get your words instantly as a variable from a result intent. you may know how to do this already, as I suspect the stt script might be broken for tasker users which is why you're confused (you'll see why I say this in the get_voice task in my project.)

import the attachment as a new project after placing it in the /sdcard/tasker/projects folder ... then run the task get_voice and stt will prompt on watch, speak, then look at the alert pop-up on the phone

and that's awesome that you're stepping into a whole new world of badass functionality
[Wear OS Software and Hacking General] pablo71:
I've been reading through your stt2file.bsh script and it's a nice addition to the wearshell command collection ... do you rename it stt.bsh and use it from an intent in tasker by typing EXTRA: bsh: stt("say something","/storage/emulated/0/talkfile.txt"); ??

I don't know how to code so I'm gonna hack this up and make use of its remote file sending abilities in cool ways.
[Wear OS Software and Hacking General] pablo71:
I tried getting this working some months ago and tried again a little yesterday ... no clue how to make it work ... tried a bunch of adb commands too couldn't get them working
[Wear OS Software and Hacking General] ertioct:
Well first of all thank you for giving me light to implement a solution based on variables, I just didn't know how to make to receive the %result. I was surprised by discovering that it's by setting a specific profile, I am very glad because it might speed up the whole process.

I just modified the header of the stt.bsh file and its name so that it wouldn't interfere with stt, so the proper way to run it is after copying the stt2file.bsh in the folder...

EXTRA: bsh: stt2file("say something","/storage/emulated/0/talkfile.txt");

Edit: I attach the stt2file.bsh with corrected help line, which could've lead you to confusion. I'd be proud if you add it to your scripts ... :good:

View attachment 4008637

It should be considered that tasker must wait for the file to appear, so we can check if the file exists by using simple unix shell command:

[ -e "/sdcard/file_you_receive" ] && echo 1 || echo 0

Below is attached the whole task to import to your Tasker (sorry if it's in Spanish, but I don't have spare time to translate it). Its basic behaviour can be resumed as follows:

1. Sends a tts to ask you a question (though voice)

2. Executes the stt2file

3. Checks if that file exists and tries to read it's content:

3.A. Once the content is read to a variable (%Tareas), goes to next step.

3.B if it haven't arrived yet, it does a couple of checking cycles (it can be configured) till it breaks into an alert via tts command.

4. Tasker checks if the command you have pronounced corresponds to a Task among all in the list.

4.A if it does exist, an attempt to run it is launched. Then waits and ... the final tts indicating you that your task has been performed. So goes next

4.B if it doesn't a tts message notifies you that the Task is not in the list.

5. It closes. :D

View attachment 4008608

Remember that the task can be executed from a modified Watchface. I have tested it on a S7 paired with a Huawei Watch and till now it works.
[Wear OS Software and Hacking General] pablo71:
oh thank you thank you! your script and task were the missing puzzle piece to compete my voice-powered-file-transfer project between phone and watch!! ... I got the phone> watch part working, but not the watch> phone half ... this is ? great
[Wear OS Software and Hacking General] mkultra329:
Thanks, you the man!

I was looking for this for a while. Now I can auto theater mode when sleeping w/ sleep as android, auto theater mode off when I wake up, and auto screen on so I can look at my wrist and check the time. That is my use case but you helped w/ the screen on event. Thank you.
[Wear OS Software and Hacking General] pablo71:
you're welcome. joschi70 helped me to clean up that code to make it simpler too. in Extra: you can use: bsh: exec("su -c input keyevent 26");
[Wear OS Software and Hacking General] dawebbreb:
At first I thought I did not have the app installed on the watch so I tried to install it through adb and I got an error saying app already exits. I requested the package list through adb and sure enough package:de.fun2code.android.wear.shell is there, however the app does not appear on my app list. What do I need to do to start it?

I tried to run this intent from tasker and it doesn't work:

Action: de.fun2code.android.wear.shell.EXEC

Extra: bsh: Runtime.getRuntime().exec("su -c settings put global theater_mode_on 1");

I also have the bsh's on the phone as well and I tried every possible action listed here like brightness and others. What am I missing??
[Wear OS Software and Hacking General] NinjaOne:
Try starting server in the Phone app. Then run your Tasker Task.

It usually makes the connection for me. Ones it works you don't have to start the server.

The app doesn't show in the app list on the watch..
[Wear OS Software and Hacking General] dawebbreb:
Just tried that, doesn't work either. So confused
[Wear OS Software and Hacking General] pablo71:
1) watch is rooted?

2) in tasker, 'external access' is granted?

3) are you running a rooted watch rom where the SuperUser app is preventing root commands?
[Wear OS Software and Hacking General] dawebbreb:
Huawei watch not rooted no special roms. Everything factory on the watch. Phone is rooted htc10 running bad boyz magisk rom. External acces enabled on tasker :confused:
[Wear OS Software and Hacking General] pablo71:
Rooted watch is required for 'most' Wearshell functions ( and changing system settings is one of them), so theater mode will require root ... I think brightness and volume and WiFi also require root as do most of the other bsh commands

I know the tts bsh script doesn't require root, and there are others too I'm sure ... you could test the tts script ( but it takes like 50 initial attempts to get watch talking, because Google tts engine has to initialize, then do first-run stuff, then download a voice file blah blah blah )
[Wear OS Software and Hacking General] dawebbreb:
Rooot! Righht! I was actually holding off rooting until Android Wear 2.0 (who knows when that will be). Besides this I didn't really see any benefits to rooting yet. Ill def reconsider now...
[Wear OS Software and Hacking General] Valiante:
Hello is there a command to toggle Bluetooth? Or even better, is the a command to toggle "play audio from phone"?
[Wear OS Software and Hacking General] vingar:
[MENTION=942616]pablo71[/MENTION] [MENTION=2829111]joschi70[/MENTION] how Can i play a file audio ? I would like to include a sound notification in the watch. Mediaplayer documentation not work for me,i tried

Inviato dal mio ONEPLUS A3003 utilizzando Tapatalk
[Wear OS Software and Hacking General] joschi70:
Do you get an error message?

What Android Wear version are you using?
[Wear OS Software and Hacking General] vingar:
Tts work with wear 2.0,mediaplayer no

Inviato dal mio ONEPLUS A3003 utilizzando Tapatalk
[Wear OS Software and Hacking General] joschi70:
Only have an old G Watch, maybe [MENTION=942616]pablo71[/MENTION] can help.
[Wear OS Software and Hacking General] BIade:
hello my friends. Im running AW2.0 and I dont like hte need for a button press. since they removed the swype-left to show apps I was searching for a workaround:

I managed to run this command through web:

bsh: Runtime.getRuntime().exec("su -c input keyevent 26");

and with this through tasker:

bsh: exec("su -c input keyevent 26");

and also with a floating icon and autowear.

But it takes quite a long time:

floating icon(watch)---BT---autoapp recieve(phone)--tasker--sent intent--BT--open app menu(watch)

Could anyone help me with a faster solution?

thank you soo much

Gratefully

Blade
[Wear OS Software and Hacking General] vingar:
Log error of mediaplayer; [MENTION=2829111]joschi70[/MENTION] ant idea?

Beanshell commad:

mp*=*mediaplayer();

mp.reset();*

mp.setDataSource("/storage/emulated/0/test.mp3");

mp.prepare();

mp.start();​

(Storage/emulated/0 is my absolute path)

BeanShell: error code bsh.ParseException: Parse error at line 1, column 19. Encountered: ;

https://developer.android.com/guide/topics/media/mediaplayer.html
[Wear OS Software and Hacking General] joschi70:
I get the same error, when pasting the sample from the pdf.

This seems to be a copy/paste problem. When typing the commands manually it ist working for me.

What are the asterisk (*) in the code, they should not be there. Otherwise this is looking good.
[Wear OS Software and Hacking General] pablo71:
I don't know how to play a sound file ... I spent a few hours once trying to get the bsh script to work but never managed to do so ... wish I could help you
[Wear OS Software and Hacking General] vingar:
The error is caused by the paste to tapatalk I tried to insert manually but always error.The link I've pasted maybe shows if something has changed on Android wear 2.It would be nice to run the sounds for the notifications

Inviato dal mio ONEPLUS A3003 utilizzando Tapatalk
[Wear OS Software and Hacking General] vingar:
[MENTION=942616]pablo71[/MENTION] [MENTION=2829111]joschi70[/MENTION] and All please We find a solution for the mediaplayer on Android wear 2, it would be nice

Inviato dal mio ONEPLUS A3003 utilizzando Tapatalk
[Wear OS Software and Hacking General] wmtype:
[MENTION=2829111]joschi70[/MENTION]

is it possible to invoke the wearshell service part on the watch itself? i would like to send an broadcast from an app on the watch to wearshell on the watch which should be delivered finaly to wearshell on the phone and picked up by tasker?

something like: am start -n de.fun2code.android.wear.shell -a de.fun2code.android.wear.shell.RESULT --ei intVariable 1
[Wear OS Software and Hacking General] joschi70:
With the current setup this is not possible. WearShell is quite phone centric and uses request codes for communication which are phone generated.

This might be possible to solve but currently the show stopper is that BeanShell cannot instantiate a BroadcastReceiver on the watch.
[Wear OS Software and Hacking General] BIade:
Is the following possible?

1) Create a "dummy-apk" which only starts an activity (i.e. open drawer)

2) Sideload the apk to the watch, and start it with a complication for example

If yes, we could make that activity a variable which could be set b4 dummy-apk-creation.

So we could export any activity as an app...

Gratefully

Blade
[Wear OS Software and Hacking General] Asiier:
Hey [MENTION=2829111]joschi70[/MENTION],

First of all, thank you very much for this app! and thank you [MENTION=942616]pablo71[/MENTION] for your profiles

Secondly, I was wondering If it was possible to either activate/deactivate DND through a command or change the ringer volume to vibration or just 0.

I have checked the recipes and the only similar thing is modifying media volume.

If they are no commands for that, are they possible to add and could we expect an update with them added?
[Wear OS Software and Hacking General] Pkt_Lnt:
There is a way though not a Wear Shell implementation. It works perfectly IF you follow the exact steps in the OP.

See this thread:

https://xdaforums.com/android-wear/development/app-disturb-sync-wear-2-0-t3603086
[Wear OS Software and Hacking General] Asiier:
Well, that doesn't work for me as I want to have my phone silence but my watch with sound.

So, my phone is in a permanent Alarm Only state (Unless it gets disconnected from the watch) and all the notifications and calls only sound in the watch.

And not sure why the setting on Android Wear app for muting calls and notifications is not working for me.

Thank you anyways as I might work something around the app

P.D.: I cannot thanks your post as I already used all my thanks for the day, I'll remember doing it tomorrow
[Wear OS Software and Hacking General] joschi70:
So that this does not get lost, here is the reply I sent to Asiier via mail:

This seems to work.
[Wear OS Software and Hacking General] LarryAlly:
Openuri is great!

I've been using wearshell for a while, mainly for tts, and I've only just realised how powerful openuri is. You can use it effectively to send intents to any app on your watch.

For example, you can pass in a Google maps uri and it will open maps on the watch at a specific location or navigation etc.

Any of the Google maps uris documented here work:

developers.google.com/maps/documentation/urls/android-intents.

My wife and I use location sharing, so I am able to tap on a hotspot on my pujie watch face and automatically open maps with a pin on my wife's current location.
[Wear OS Software and Hacking General] LarryAlly:
Invoking Tasker from the watch

If you just want to trigger a Tasker task from the watch there are much easier ways. For example, Autowear and the Pujie watch face both provide Tasker plugins and allow you to call Tasker in many different ways.