How can I pass a variable to a KM macro activated using Shell script?

I came across a program, lincastor than can change the default handling of URLs. I am trying to create a macro that will download a magnet link to my seedbox.
The shell script in the app launches my macro but I have no idea how to pass the URL variable across to the macro. How do I achieve this?

Version 7 will let you pass a parameter when you invoke a macro via AppleScript.

Until then, you need to stash the URL somewhere the macro can get it. For example, write it to a file /tmp/url-for-km.txt, and then have the macro read that file into a variable.

Or write it to a Keyboard Maestro variable.

That looks easy enough.

But keep mind that LinCastor is beta software that hasn’t been updated for over 6 months.

-Chris

1 Like

Thanks. Is there any software with similar functionality that is stable?
I want to trigger a macro automatically for any safari web address containing http://www.ncbi.nlm.nih.gov .

How do I write it to a variable name. When I tried:

echo $URL >> $KMVAR_variable_magnet

I kept getting an ambiguous redirect error.

Hey Mirizzi,

I suspect that you can change the HOSTS file on your system to accomplish that.

These links give you a little idea of what can be done:

http://someonewhocares.org/hosts/

I have not done this, so I cannot give any advice based on experience.

It seems to me that Peter has a url-scheme for Keyboard Maestro, so it might be easy to redirect the domain in question to a km-macro-url.

But you'll have to ask Peter.

-Chris

Hey Mirizzi,

You have to know what you’re doing.    :smile:

>> is trying to redirect output to a FILE and append it.

Post the whole script.

-Chris