Passing a KM Variable to another Mac in same Network

Is it possible to send a Keyboard Maestro variable from one Mac to another one which is in the same network, and both have Keyboard Maestro installed?

I tried with Applescript:

27

But I don´t know what do on the second Mac to grab this Variable. My aim is to send the Variable over and trigger another Macro there to save the Variable in Clipboard together with a Notification

1 Like

One solution might be to use SSH, if you don't mind running sshd on the other Mac. (You can enable it under System Preferences, Sharing, Remote login)

Execute a shell script like this:

ssh MYUSERNAME@Pierres-MacBook-Pro.local "osascript -e 'display notification (\"Some text here\") with title \"Some title here\"'"

You would also need to set up a public key on your first machine, and add it to the authorized_hosts file on Pierres-MacBook-Pro.local, but it's probably a pretty clean/secure way to do it.

Just to explain what I'm doing real quick:

  • Connect via SSH to your laptop
  • Execute an AppleScript (using the command osascript)
  • Use the built-in display notification from AppleScript to show the notification (escaping the double quotes, because we already used those for the SSH-command)

Hope this helps!

1 Like

Hey @MartijnEngler, thanks for your reply and the idea. SSH sounds good,I just set up a public key and add it to the macbook. But I found another shell script, that directly copy the clipboard to the laptops clipboard:

pbpaste | ssh USERNAME@pierres-mbp.fritz.box pbcopy

15

So I just set my variable to clipboard and start this shell script. Thanks again for the idea!

1 Like

Looks like you have a solution that works for you, but for those that don't want to use SSH, or would like a more general solution, here's an untested idea:

  1. Use a Cloud sharing tool like DropBox or iCloud, and create a "KM Variables" folder that both (all) Macs can read/write to.
  2. To set a KM Variable, just write a text file using the KM Variable Name as the file name to that folder.
  3. Then any Mac that wants sync to any KM Variable, can just read that file.

You can use the KM Actions to do the write/read:

I like this approach because:

  1. You can always view what the current sync'd value is
  2. Dropbox offers a file history so you can restore from a prior version easily

Make sense?

2 Likes

Definitely a good solution, especially if one of the Macs are not in the same network. Will use that for other projects!

1 Like

You can use the Remote trigger with a parameter value to send a value to another Mac (and execute a macro on the target Mac at the same time of course).

1 Like

Just wanted to chime in on this old discussion. I needed to pass a variable from my laptop to my iMac every hour. I found the Remote Trigger did not always operate reliably on the Mac. I realized, though, that creating a folder in iCloud (or DropBox) if my value is True or deleting said folder if False gets the job done just as well.

Thanks for the info!

Hey Peter,

I would probably write a value to a given file rather than creating and deleting a folder – but YMMV.

-Chris

That sounds really good.

I want to trigger different macros on my second Mac from my first Mac.

(The first Mac is attached to a Stream Deck and I want to use the Stream Deck to trigger videos, clips and animations on my second Mac. The second Mac is hooked to an ATEM mini using HDMI and I can then mix that channel to my program flow. The Program is used as a web cam in Zoom on my first Mac)

My thinking was that I set up macros on the first Mac and link them to buttons on the Stream Deck. The macros then trigger other macros on the second Mac. It feels like that should work but I have yet to find a way to do it.

I would like the most reliable way of doing it and I don't have experience in setting up the Remote trigger.

If anyone has some ideas, I would be very grateful to hear about them.

Thank you in advance.

Best Regards
Johan Niklasson

Create a macro on the target Mac, give it the Remote trigger.

Add an Display Text action, and display the text in a window, displaying %TriggerValue%.

Copy the URL of the remote trigger.

On the source Mac, add a Remote Trigger action. In the Parameter field, type “1234”. In the trigger field, include only the ID part of the URL - remove the https://trigger.keyboardmaestro.com/t/ from the front, and the ?TriggerValue from the end.

Clicking Try on the source Mac should show the “1234” on the target Mac.

1 Like

Thank you so much for this. I will try it and if it works well, post some instructions and samples.

Best Regards
Johan Niklasson

I have tested it as you described and it works!

This is such a great tool and it will help me tremendously in my workflow. Thank you very much!

Best Regards
Johan Niklasson

1 Like