Sync Clipboards

I'm currently running KM on two Macs and have synchronized all macros from the old one to the new one. However, when it comes to clipboards, only their names have been synced to the new Mac.
Isn't it possible to transfer them as easily as the macros? It seems weird to be able to sync a macro depending on a specific clipboard image without syncing the image itself.

1 Like

Thanks @PJMorten for this question.

I was thinking about this for a long time but didn't have the time to search for a solution. Today I again searched the forums but wasn't able to find something.

So I'm also asking this question. Is there a smart way to synchronize Named Clipboards between two or more Macs?

Hi @PJMorten and welcome to the Forum!

To achieve this I use the "Set Clipboard to File" Action in Keyboard Maestro. And I make sure the path to the file is the same on each computer. In my case I keep the file in Dropbox (so that is how the Sync is handled). A real-world example is that I wanted to paste in a Map showing directions in an email and wanted to paste in the same image whatever computer I was working on.

EXAMPLE Set Clipboard to File and Paste.kmmacros (26.3 KB)

1 Like

Thanks so much @Zabobon. That is indeed a great idea and I have to check it out for my tasks.

Currently I am busy with other things and can't try it but it looks like we are limited to a specific file type like either image or text or sound file, whatever it is.

Beside others, I'm using the named clipboards a lot for i.e. eMail templates to answer customers of my web shop and these contain text and images (logos for the signature) in most cases. Maybe a sequence with more steps like shown in your example might help but this is again quite some effort to kind of "puzzle" the components together.

But again, thanks anyway. Much appreciated. I'll definitely will think it over as soon as I have a little time to.

1 Like

You probably already know, but there is a very powerful Keyboard Maestro Action to generate an email with lots of specific things that can be set (including standard message body text). I use this a lot to quickly start emails and can be used in conjunction with Keyboard Maestro Variables to make even more functional.

Thanks again. Indeed I never worked with this action. But in my special case it probably wouldn't work because I am using these mostly to answer specific and kind of repeating requests from customers.

@PJMorten @Hans-Peter_Henkel And, on the subject of reading the contents of files and making use of that content, the Wiki says it better than me:
https://wiki.keyboardmaestro.com/action/Read_a_File
The contents can not only be read to the Clipboard but also to Keyboard Maestro Variables.

The named clipboard is saved at /Users/yourmacname/Library/Application Support/Keyboard Maestro/Keyboard Maestro Clipboards.kmchunked

So just copy it from the old mac n replace the one in new mac

Hope it can help u

Thank you all so much for your help and recommendations. Again I learned a lot.

@Marcc: Thanks also and indeed this would be a solution if I just want to move once from one system to another. But I am working as a freelancer, partly in my office and (without pandemic) partly all around the world. Before I now found my hopefully lasting solution thanks to @Zabobon I always had troubles when I wanted to use my macros sitting in the hotel room from my MacBook Pro.

I first tried to change my workflow from the Named Clipboards to "Read a File". It worked but in some cases I have logos included which caused a small delay. Even though it was acceptable I now went back to my previous used Named Clipboards but created a Macro, that synchronizes all Named Clipboards that I use for this purposes from files on my Dropbox. I tried to use the trigger "At logIn" to automatically sync them but it doesn't seem to work. I have to check and maybe investigate furthermore in the future. But I also created a shortcut which I can easily use, so it is not really a problem. Being able to now use my Clipboards everywhere like this is a huge step forward to me.

Of course it would be even more comfortable if the content of Named Clipboards could be synchronized with the macros. Maybe something to consider for the next bigger update? :wink:

1 Like

Hi @Hans-Peter_Henkel. Now that @Marcc has shown the path to the Named Clipboards there should be a simpler solution to syncing them via Dropbox (or any other Cloud Based drive).
As I never actually use Named Clipboard in my Macros (not for any great reason, just never needed to) I hadn't looked into syncing them before.
But... if a Symlink was put at the location Keyboard Maestro wants to store the Named Clipboards and this Symlink pointed to the folder on Dropbox and if each Mac had the same setup with a Symlink at /Users/yourmacname/Library/Application Support/Keyboard Maestro then... in theory I don't see why the same Named Clipboards wouldn't be available on each Mac.

[EDIT from @peternlewis - DO NOT DO THIS, it will potentially result in data loss]

As this is such a simple solution I wonder if there is a catch to using Symlinks to have the same Named Clipboards on each Mac. Perhaps @peternlewis could advise?

Thanks again, looking forward to whatever is possible. Currently I am happy with my solution which is a big improvement for me compared to the situation before.

Enjoy your Sunday anyone!

1 Like

Thanks a lot. This is a very interesting way and again something to learn for me. I just need to focus on other things right now but will definitely investigate a bit more as soon as I have the chance to.

1 Like

Do not do this.

Changing files in the Keyboard Maestro application support/preferences folder underneath Keyboard Maestro will result in data loss.

1 Like

Thanks for the correction @peternlewis. I knew there had to be a reason not to do this as it seemed too obvious.

Out of interest do you think you will ever include syncing of Named Clipboards along with the built-in syncing of Macros?

I'm not sure. Syncing in generally is a very hard problem (which is why you still hear from people who lose data to iCloud syncing, etc). Except for one-way syncing, it is very challenging and dangerous, and so I am reticent to try to implement it. The macro syncing is based off other people’s syncing engines, and even that results in problems regularly for folks when there are conflicting changes.

It is certainly possible that I could implement something similar to the macro syncing, but then just like macro syncing you get in to trouble with only wanting some parts synced, and clipboards can be extremely large, especially when they contain images.

So while I won't say it will never happen, I wouldn't hold my breath waiting either.

1 Like

Hey Peter,

What files would need to be synced?

Keyboard Maestro Clipboard History.kmchunked
Keyboard Maestro Clipboard History.plist
Keyboard Maestro Clipboards.kmchunked
Keyboard Maestro Clipboards.plist

These would be easy enough to transfer by hand, and it wouldn't take too much to write a macro to do it with ssh and rsync.

Methinks the only pitfalls would be to make sure the Keyboard Maestro Engine on the receiving Mac was not running and to not use the clipboard on the sending Mac until the sync was complete.

Am I missing anything?

-Chris

You don't need the plist files, the kmchunked files replace them.

You can transfer them as long as you make sure that Keyboard Maestro and Keyboard Maestro Engine is not running on the local Mac when you copy them from there, and not running on the target Mac when you copy them to there. Even then the current system clipboard will be preserved on the target Mac.

Anything else may result in corruption, and obviously it is not really syncing if you cannot make changes on either Mac and have it propagate, so unless you are careful to quit Keyboard Maestro and Keyboard Maestro Engine, and transfer the files whenever you leave the Mac, it's going to overwrite data.

There are also the variables of course.

Hey Folks,

Okay – the bottom line is that if you need to be able to fully synchronize Keyboard Maestro between two or more Macs it can be done although not automatically.

  • Relevant Keyboard Maestro files could be copied by hand between Macs.

  • A 3rd party sync app could be used to do the job.

  • An AppleScript could be written to do the job.

  • A shell script could be written to do the job.

I personally would probably use the shell and run the job with the Apple Terminal.app or iTerm.app. I prefer a Terminal UI in this case, so I can run the job verbose and watch what it's doing.

If I was going to script the job without the Terminal, I'd use FastScripts, because it allows me a run-script mechanism (AppleScript & Shell Scripts) outside Keyboard Maestro which makes quitting all running versions of KM simple.

-Chris

2 Likes