yashsingh1/xdaforums huggingface dataset:
[Wear OS Software and Hacking General] Pkt_Lnt:
I'm trying to figure out if I am doing something incorrectly, or if my device is the issues, since it is a Samsung Gear 2 running a Android Wear port, The watch work perfectly with everything but trying to run Tasker intents via WearShell. Here are some screen shots to show my attempts to use the new version with the files and commands you just posted.
[Wear OS Software and Hacking General] Pkt_Lnt:
And a couple more showing that Wear Shell is on the watch and some system info
[Wear OS Software and Hacking General] joschi70:
Maybe your external storage device is not /sdcard.

You can execute the following script inside the shell to find the location of the external storage:

import android.os.Environment;
print(Environment.getExternalStorageDirectory().getAbsolutePath());

Try to place the bsh folder there.
[Wear OS Software and Hacking General] Pkt_Lnt:
It returns

/storage/emulated/0

which is the same as

/sdcard

since it is symlinked in Marshmallow 6.0.1 on a Nexus 6

So

/sdcard/bsh

is the same as

/storage/emulated/0/bsh

It sounds like this is pointing the the device as the culprit.
[Wear OS Software and Hacking General] joschi70:
Sorry, if this is a stupid question...

Is the bsh directory located on your phone or your watch?
[Wear OS Software and Hacking General] Pkt_Lnt:
No, that is me. I just went and looked at the install instructions again and I had placed them on the phone. Duh!

I have been trying to get Tasker intents to change brightness on my watch and I was too excited and under caffeinated when I saw your post of the new version, that I overlooked that.

I'll slink off with my tail 'tween my legs and fix it.

Thank you!
[Wear OS Software and Hacking General] vingar:
For me...with gear2 dont work!

My path is /storage/emulated/0

Example shell work...

New command nothing!

What is the problem?

I put in shell (is correct?):

vibrate(2000);

Error log:

BeanShell: error code bsh.EvalError: Sourced file: inline evaluation of: ``vibrate(2000);'' : Command not found: vibrate(int) : at Line: 1 : in file: inline evaluation of: ``vibrate(2000);'' : vibrate ( 2000 )
[Wear OS Software and Hacking General] vingar:
joschi most file into your zip command are empty 0kb !!!

I was going crazy!!

Please reupload !

I test volume (not empty and work!!)

Inviato dal mio SM-N9005 utilizzando Tapatalk
[Wear OS Software and Hacking General] Pkt_Lnt:
Did you create the /bsh directory on the watch and put the scripts in it?

The zip file is fine. Download on a computer.
[Wear OS Software and Hacking General] vingar:
Yes,but if you extract zip... See most file 0kb,empty.

Inviato dal mio SM-N9005 utilizzando Tapatalk
[Wear OS Software and Hacking General] Pkt_Lnt:
Yup, just confirmed/
[Wear OS Software and Hacking General] joschi70:
Uups ... sorry!

File has been re-uploaded.
[Wear OS Software and Hacking General] vingar:
If i want use tts bsh into send intent from tasker?

Action = de.fun2code.android.wear.shell.EXEC ???? (Is correct?)

And extra: ???

Thanks

Inviato dal mio SM-N9005 utilizzando Tapatalk
[Wear OS Software and Hacking General] joschi70:
Here is a sample extra:

bsh: tts("TTS test from Tasker", Locale.ENGLISH);
[Wear OS Software and Hacking General] vingar:
With tasker work very well! Thanks.

Now i must find a way for modify the bash for work with Loquendo TTS.

PS: loquendo tts work very fine into watch!

Inviato dal mio SM-N9005 utilizzando Tapatalk
[Wear OS Software and Hacking General] joschi70:
Inside tts.bsh you can change the package name of the TTS engine.

For Loquendo TTS that should look like this (not tested):

TTS_PACKAGE = "appinventor.ai_raul_kpr.loquendo1";

Hope this is the correct TTS engine.
[Wear OS Software and Hacking General] pablo71:
ohhhh this is fantastic! I can't wait to get off work to try it out .. thank you!!
[Wear OS Software and Hacking General] pablo71:
"The Wearshell Command Collection" ... haha now THIS is good stuff I love it ... I'm having to fumble for my phone less and less with these clean lean stable solutions that keep my eyes on the road ...thanks joschi
[Wear OS Software and Hacking General] pablo71:
problem with wearshell 5.0 install

looking for some advice, and/or an upload of the wearshell 5.0 companion app that goes on watch app I can sideload it

my problem:

wearshell 5.0 won't install companion app on watch when doing a fresh install after an uninstall of 4.2, so no commands work.

updating from 4.2 to 5.0 leaves previous companion app on watch, and old commands work, but not new commands.

rebooted phone and watch many times

commands unzipped and placed into /sdcard/bsh, I even tried /sdcard/0/bsh but still nothing.

is there a way to sideload the companion app for 5.0 to get it working? maybe Android Wear is getting in the way somehow.

phone: Samsung galaxy note 3 kk4.4.2 rooted touchwiz based rom with xposed framework and TWRP recovery

watch: huawei watch rooted 1.4MM and a custom kernel by skin1980 TWRP recovery
[Wear OS Software and Hacking General] joschi70:
No idea if this will work, give it a try:

https://goo.gl/VtfPgh
[Wear OS Software and Hacking General] pablo71:
sideload got that installed, and it accepts the old commands, but not commands from the "Wearshell Commands Collection" ....

...I'll try and just paste all those scripts into the "Extra" field in a tasker intent after inputting variables manually and see what happens

---------- Post added at 11:32 PM ---------- Previous post was at 11:20 PM ----------

I got vibrate to work after cutting up script to put this into "Extra":

bsh: import android.content.Context; vibr = context.getSystemService(Context.VIBRATOR_SERVICE); vibr.vibrate(2000);

that works with wearshell 5.0 phone app and sideloaded 5.0 companion app.... I have no real idea what I'm doing but. I think I can trial+error the other commands to work so I think I'm happy! these commands are great and push, pull, volume, vibrate, tts, unzip look like awesome scripts , so thank you again
[Wear OS Software and Hacking General] pablo71:
I'm having trouble modifying the tts script to work as an intent, is it possible

or is the syntax incompatible? if I remove spaces between {} and replace variables with values could it work?
[Wear OS Software and Hacking General] joschi70:
Haven't tested, but I think that should work.

What you also can do is to leave the script on the Wear device. You can load it with the source command:

source("/sdcard/bsh/tts.bsh");
tts("test", Locale.ENGLISH);
[Wear OS Software and Hacking General] pablo71:
[SOLVED:] Had to unpair watch from phones BLUETOOTH SETTINGS (not Android Wear app)

thank you for the help... I tried above commands and many variations of them with "bsh:" in the beginning of the intent in the "Extra" section but couldn't get above command to work.. do you think a variation of the above command written something like this could work:

bsh: Runtime.getRuntime().exec("su -c source('/sdcard/bsh/tts.bsh'); su -c tts('test', Locale.ENGLISH);")

Also, in the wearshell server I tried:

source("/sdcard/bsh/tts.bsh");

tts("test", Locale.ENGLISH);

and I got this error:

BeanShell: error code bsh.TargetError: Sourced file: inline evaluation of: ``source("/sdcard/bsh/tts.bsh"); tts("test", Locale.ENGLISH); ;'' : Method Invocation this.interpreter.source : at Line: 14 : in file: /bsh/commands/source.bsh : this .interpreter .source ( filename , this .caller .namespace )

Called from method: source : at Line: 1 : in file: inline evaluation of: ``source("/sdcard/bsh/tts.bsh"); tts("test", Locale.ENGLISH); ;'' : source ( "/sdcard/bsh/tts.bsh" )

Target exception: java.io.FileNotFoundException: /storage/emulated/0/bsh/tts.bsh: open failed: ENOENT (No such file or directory)

I tried marketing the directory /storage/emulated/0/bsh with mkdir commands to copy the scripts in /sdcard/bsh into ... could this mean I have to make a /storage/emulated/0/ directory and make a symbolic link to /sdcard/ ??

EDIT: I don't have a /bsh/ folder in root directory ... am I missing a component that wearshell 5.0 tried to install but couldn't?
[Wear OS Software and Hacking General] pablo71:
[SOLVED:] Had to unpair watch from phones BLUETOOTH SETTINGS (not Android Wear app)

hmm.... I have a second Huawei Watch identical to first one, and sideloading the Wearshell 5.0 companion app onto it gets all commands working as they should from the /bsh/folder... so these two watches aren't as identical as I thought. all old commands from 4.2 work on both, but it's 5.0 where the difference is exposed .. both watches flashed with same system image, and same recovery image...but I didn't reflash a stock boot image to this second watch that plays better with wearshell 5.0 .... if I find out what's different I'll post why 5.0 companion app isn't fully functional on first watch
[Wear OS Software and Hacking General] joschi70:
You can check the WearShell version on the watch with the following command:

print(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName);
[Wear OS Software and Hacking General] pablo71:
wear output says 0.5.0 on both watches ... your app is solid and working great for me. unpairing the problem watch in the phones bluetooth settings (instead of unpairing it in the android app) got 5.0 working immediately ... when I switch watches they are both connected for about 30 seconds simultaneously, and I think this is a bad idea since they both are identical configurations ... I think this caused some corruption in my Bluetooth cache or something ...

you've been extremely helpful and I appreciate it ... the new version is running great and the wearshell command collection is awesome ... wearshell+tasker is like 100 wear apps all in one and stable and low resource ... the battery use of your app on my phone is virtually zero (according to the apk of Better Battery Stats I sideloaded)
[Wear OS Software and Hacking General] Pkt_Lnt:
Ok, I have brightness working, even it it took a different watch. ;)

In WearShell, with the brightness.bsh in the watch /sdcard/bsh/ the commands to change brightness work fine.

brightness (254): same as 5 in settings
brightness (106): same as 1 in settings

Mini Wear Launcher has a brightness slider that can drop lower still, but I cannot read the brightness in WearShell with the command

brightness ():

It just gives nothing in the Wear Output window.

Is that read brightness level correct?
[Wear OS Software and Hacking General] joschi70:
Try so surround it with a print() statement:

print(brightness());
[Wear OS Software and Hacking General] Pkt_Lnt:
That got it, perfect, thanks. I need to brush up on some of the basics of this.
[Wear OS Software and Hacking General] pablo71:
Result Intents In Tasker ?

I've read the docs and the forum regarding result and %RESULT but I don't know how to make it work in tasker ... if I wanted to send a command to, say, see the contents of a folder in an intent like EXTRA bsh: Runtime.getRuntime().exec("su -c cd /sdcard/; su -c ls;"); then how could I catch the response in tasker in this variable called %RESULT? ... do I create a tasker profile to receive the intent? thank you
[Wear OS Software and Hacking General] joschi70:
You could strip down your BeanShell code like this:

exec("ls /sdcard/");

That should give the same result.

As far as I read from the Tasker docs, you can create a new profile with an Event -> System -> Intent Received with the following settings:

Action

de.fun2code.android.wear.shell.EXEC_RESULT

If a broadcast Intent is received Tasker should automatically set the following variables:

%result

%requestCode
[Wear OS Software and Hacking General] pablo71:
oh this is great man ... lots of new possibilities with this ... ii appreciate the info
[Wear OS Software and Hacking General] joschi70:
WearShell Command Collection 2 is available.

It contains the following commands:

battery

md5

notify

record

showimage

startapp

sysload

toast

uptime

zip

Hope it's useful ....
[Wear OS Software and Hacking General] pablo71:
tts script question

[EDIT: Thought I fixed, still downloading an update]will it break tts to edit the tts script to prevent Google engine from checking the package and/or updating it? I ask because my built in tts on my watch sounds fantastic, but just once, then Google updates it and it sounds bad. I'm not complaining, I'm happy. if I "CLEAR DATA" on the tts engine it sounds great again once, but just once, then updates and sounds bad. I'm also hoping that the tts will start working faster and more reliably if update and package checks can be removed from script. thank you joschi

[MY SOLUTION - which didn't with completely]

I removed these lines from tts.bsh script:

try {

pm.getPackageInfo(TTS_PACKAGE, PackageManager.GET_ACTIVITIES);

}

catch(e) {

gs.put(STORAGE_KEY, null);

print("Package " + TTS_PACKAGE + " is not installed.");

print("The package can be downloaded from: https://play.google.com/store/apps/details?id=" + TTS_PACKAGE);

return null;

}

I don't know if this will cause trouble or break something, but for now tts seems to fire up right away, without too long an initialization, but it still downloads that nasty update which makes tts sound pretty awful...hmm
[Wear OS Software and Hacking General] pablo71:
just an fyi: I converted the wearshell 0.5.0 wear app to a system app and it survives factory resets beautifully on huawei watch running Android 1.4 ... very cool
[Wear OS Software and Hacking General] joschi70:
If you have a different TTS engine installed you can use it instead of the Google TTS.

Just change the following line inside the tts.bsh command script:

TTS_PACKAGE = "com.google.android.tts";

The TTS_PACKAGE specifies the package name of the TTS engine to use. Replace com.google.android.tts with the package name of your already installed TTS engine and it should work.

You can get the installed TTS engines by executing the following script:

import android.content.Intent;
import android.content.pm.PackageManager;
import android.speech.tts.TextToSpeech;

intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);

pm = context.getPackageManager();
list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);

for(info : list)​ {
print(info.loadLabel(pm) + " (" + info.activityInfo.applicationInfo.packageName + ")");
}
[Wear OS Software and Hacking General] pablo71:
thank you again, this helps.
[Wear OS Software and Hacking General] pablo71:
Wearshell makes High Quality Online TTS Fast and Easy

http://xdaforums.com/android-wear/development/tutorial-quality-voice-tts-quick-hack-t3378486

Where I live I've got pretty decent data service, and since everything tts could read to me comes through data anyways, why not use online tts .

.
[Wear OS Software and Hacking General] pablo71:
]I just got the Wearshell Command Collection 2 working and they are working great on my Huawei watch I had to add the .bsh file extension to the scripts to get them working.

question: if anyone knows how to configure a task in tasker to get the data for the 'battery' and 'uptime' wearshell commands I'd appreciate it. I did some reading and experimenting to get result intents working with tasker but I couldn't only get the ResultCode not Data. as per the examples, using the print command in the wearshell web interface works, but I'd like to use this data in tasker. thank you
[Wear OS Software and Hacking General] joschi70:
Here is an example that is reading the system load of the watch using the sysload() command.

Changing this to read battery status using the battery() command will work the same way.

Here is a link to the Tasker profile import files and a short description:

https://goo.gl/fgI1x3
[Wear OS Software and Hacking General] pablo71:
right on man way cool thanks....yeah this is really cool I greatly appreciate this
[Wear OS Software and Hacking General] pablo71:
this is fantastic .. in tasker I'm sending shell commands that include variables to wearshell and receiving the output from wearshell in tasker and converting this output to variables that can trigger other profiles and tasks .. thanks joschi this is great
[Wear OS Software and Hacking General] pablo71:
add some spice to joschi's tts script

joschi wrote us an awesome tts script for tasker usage that gets used on my watches at least 50 times a day....

.... if you want to spice it up in tasker try Locale.UK , or Locale.JAPAN or Locale.FRANCE

all my profiles trigger tasks with Locale.UK since that is most understandable to me and stock American English sounds yucky

NOTE: the first couple times you try a different locale you'll get high quality online voice, then it downloads the voice pack which is good, but not as good as online (but the voice pack works offline.) if you wanted to just use the high quality online voices then use the app Advanced Settings to CLEAR DATA on the system app Google Text To Speech Engine and then in same menu DISABLE download manager. this forces android to just keep using online voices.

either way thanks joschi
[Wear OS Software and Hacking General] 123marvin123:
I always get an error, no matter what I am trying to do (on the web interface):

BeanShell: error code bsh.EvalError: Sourced file: inline evaluation of: ``importCommands("/");'' unknown error: throw with null exception : at Line: 1 : in file: inline evaluation of: ``importCommands("/");'' : importCommands ( "/" )

This issue might be related to Android Wear 2.0 Preview (Huawei Watch).
[Wear OS Software and Hacking General] joschi70:
I don't own a Huawei watch, so this is hard to tell.

Is there an error message in the logcat?
[Wear OS Software and Hacking General] 123marvin123:
There is no error on the watch itself, I just see a "06-05 18:21:28.539 2861 2861 D WearShell: Wear connected!".

And on the phone (OnePlus X 5.1.1) I just get a "D/WearShell(22086): Connection ok!"

So no, there is no error in the logcat. This is how the error looks like in the Web UI:

fs5.directupload.net/images/160605/ojin5okj.png
[Wear OS Software and Hacking General] joschi70:
Did some debugging, seems like this is an Android N Preview issue: https://code.google.com/p/android/issues/detail?id=209557

Hope this will get fixed in the next preview.
[Wear OS Software and Hacking General] Sekasniy:
Hello. Is possibile keep screen on sometimes? I have tried to create wakelock, but display off whatever.
[Wear OS Software and Hacking General] joschi70:
You could try the following script:

import android.content.Context;
import android.os.PowerManager;

STORAGE_KEY = "_wakelock";

keepScreenOn(state) {
gs = globalStorage();
wakeLock = gs.get(STORAGE_KEY);

if(wakeLock == null) {
powerManager = context.getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
"WearShell WakeLock");
gs.put(STORAGE_KEY, wakeLock);
}

if(!wakeLock.isHeld() && state) {
screenOn();
wakeLock.acquire();
}
else if(wakeLock.isHeld() && !state) {
wakeLock.release();
}
}

Calling keepScreenOn(true) should switch the screen on and keep it on. To release the WakeLock use keepScreenOn(false).

You can also save the script to /sdcard/bsh/keepScreenOn.bsh and it will be available as command.
[Wear OS Software and Hacking General] joschi70:
WearShell 0.6.0 has just been released. It includes support for Result Intents, sensors support and bug fixes.

Along with the new release comes the Command Collection 3, which includes the following commands:

alarm

charging

freestorage

heartrate*

light*

stepcount

stt

timer

wifioff*

wifion*

Commands marked with * I could not test because my G Watch is lacking the sensors and WiFi support. If you find any errors please let me know, I'll try to fix them.
[Wear OS Software and Hacking General] pablo71:
oh right on! command collection 3 looks dope .. installing now thanks joschi
[Wear OS Software and Hacking General] pablo71:
how to get stt.bsh script to work?

in a tasker send intent action nothing happens and when I try " print(stt("Speak")); " in the wearshell server I get this error message:

BeanShell: error code bsh.EvalError: Sourced file: inline evaluation of: ``print(stt("speak")); ;'' : Command not found: resultIntent(android.content.Intent) : at Line: 20 : in file: /stt.bsh : resultIntent ( intent )

Called from method: stt : at Line: 1 : in file: inline evaluation of: ``print(stt("speak")); ;'' : stt ( "speak" )

any ideas? thank you
[Wear OS Software and Hacking General] joschi70:
Seems like the internal command resultIntent() cannot be found. This is a new command in WearShell 0.6.0.

Can you please check if you are running the latest WearShell version on your watch:

print(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName);
[Wear OS Software and Hacking General] pablo71:
EDIT: ok, I found the 6.0 watch apk in your downloads folders getting it now
[Wear OS Software and Hacking General] pablo71:
[SOLVED: got it working by using beanshell server usage versions in tasker]

not getting result intents in tasker for stt.bsh or freestorage.bsh the way you instructed. how do you get the results in tasker?

as an example as per your instructions this would let me view the top running processes on the watch in tasker

SEND INTENT:

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

Extra:

bsh: exec(" su -c top -s cpu n 1;");

Extra:

requestCode: 99999

....and setting up the profile

EVENT> INTENT RECEIVED:

Action:

de.fun2code.android.wear.shell.EXEC_RESULT

....and the task it triggers

ALERT / POP-UP:

Text: %result%

If: %requestcode ~ 99999

[SOLVED: this is good enough for me at least]

SEND INTENT:

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

Extra:

bsh: print(stt("Speak Now"));

Extra:

requestCode: 96969

....and setting up the profile

EVENT> INTENT RECEIVED:

Action:

de.fun2code.android.wear.shell.EXEC_RESULT

....and the task it triggers

ALERT / POP-UP:

Text: %result <--just one '%' this time

If: %requestcode ~ 96969
[Wear OS Software and Hacking General] pablo71:
The Big Question

Can intents be sent directly to wearshell WATCH app from WITHIN the watch? Or shell commands to activate scripts?

... I ask because I sideloaded a tasker apk mini-app INSIDE the watch and it recognizes wrist gestures quite well -- if it could send an intent or command directly to the wearshell app INSIDE the watch to launch the stt script that would increase the functionality of the watch hugely by allowing unlimited custom voice commands (and bypassing the need to say Ok Google would be great)

... I read the android manifest xml for the watch app and I see it listens for stuff coming to it through com.google.android.gms, ( I guess this is the communication link through android wear and Google play services etc ) .. I couldn't see a way to send an intent to it directly ... thank you
[Wear OS Software and Hacking General] TheGoD:
What are result intents? Sorry if is obvious.
[Wear OS Software and Hacking General] pablo71:
joschi could explain this better, but an 'intent' is (1) a command sent FROM THE PHONE through Wearshell that causes something to happen on the watch whereas (2) a 'result intent' causes something to happen on the watch AND THEN GATHERS THE RESULT of it and sends the result to the phone for use in other applications, like say Tasker.

my current favorite result intent uses joschi's sst.bsh (speech to text using Google's voice recognizer) script in Wearshell Commands Collection 3 ...I press the microphone icon on my watchface (pujie black) that triggers a tasker task to send an 'intent' to watch through wearshell to activate voice recognition, then I speak a custom command I've created in tasker, then the 'result intent' (which are the words I spoke) are returned to the phone through wearshell and dumped into tasker as the variable %result, then that custom command makes things happen on watch, phone, or both.

these result intents could be heartrate, step count, battery level, free storage, system load, a files contents, spoken words, basically anything happening on your watch OR the results of what you make happen.

( ugh .. I talk too much )