Well it looks like I can now pass data from KWGT to MD via broadcast intent. It's not as pretty as I would have hoped but it seems to work albeit after a fashion. It ended up being a mix of so many different ideas that in the end it was found by accident. Perhaps the answer was already out there but it just took longer for it to start working with my setup.
In MD I have a macro which is triggered by a receive intent. The action at the top is just one word - "triggertask". It doesn't have to be more than one word and can be anything you like really. That's how I've always set them up and they work. There are two
string "extras" that are setup in the receive intent, namely 'xfromapp' and 'xindata', the x prefixes are just to remind me that they are the extras. They are both saved to local variables with the same name minus the x prefix. Anything really.
It's a good idea to setup another separate macro that
sends an intent out to test the first macro that receives them. When you setup the send intent, set the target to 'broadcast', the action to 'triggertask' (or whatever you want = same as the receive intent action) and the package to 'com.arlosoft.macrodroid'. Don't forget to setup the extras at the bottom too, in my case there are two and they are of type
string and are called 'xfromapp' and 'xindata'.
The last thing in MD is to create two local variables inside the receive intent macro. This is where the received data from KWGT will be held. I just called them the same as the extras above but without the x prefixes. Whatever.
In KWGT/KWLP a new widget/shape is created. Firstly, in the root of the widget add a new flow. Doesn't matter what name it is. Flow000 is fine. Set the trigger to 'Manual' and then add a new
formula action.
Now for the bit which still puzzles me.
Set the formula to the following...
$sh("am broadcast --user 0 -a triggertask -e xfromapp KWGT -e xindata smelly")$
It basically tells KWGT to run a shell command (application manager I think
) and gives it certain parameters. Our -a or action 'triggertask' is there. The two separate -e or extras parameters are there. The two strings I passed were "KWGT" to xfromapp and "smelly" to xindata. They are just strings. They can hold any text you like.
What I don't understand yet is what the "--user 0" part does. I also don't know why I don't have to specify the com.arlosoft.macrodroid as a package anywhere. In truth it used to be there when I was playing around with it and it was only as soon as I had deleted it that it fired the macro to my amazement.
What's also annoying is that it doesn't always fire when the Kustom widget or shape is pressed. What I mean to say is it that after about a minute it works again. My guess at the moment is that I might need to add a flag in the command line that clears something immediately ready for the next press or something.
Either way, it's a step in the right direction. Just needs refining now to make it have a better response.