Sync Variables?

Hi guys I’m new to KM, porting over from Quickeys.

I was just starting a series of shortcut ports into KM, using variables, when I found out that the variables are not synced. Wow this was a disappointment because I thought KM was going to save me from my old Quickey workarounds of saving folder names in Dropbox as values I needed to share in variables. To rework all those using the same hacky workarounds will be so tedious.

Is there are way then in KM7 to do this? Please please give us a variable that can be selected to have the value synced. The Macro syncs, the variable NAME syncs but not the value.

Hey David,

I have a suspicion Peter won’t like that idea, but he’ll chime in and we’ll find out for certain.

In any case it’s easy to create a preferences folder in Dropbox and read/write to files.

File on-disk:
~/Dropbox/KM_Prefs/NoteFilePath.txt

KM action:
Read file ~/Dropbox/KM_Prefs/NoteFilePath.txt

You don’t need the .txt suffix, but that makes it easer to view from Quick Look, etc.

If you know a little regex you can get pretty sophisticated, but simple read/write is easy and fast.

-Chris

Thanks for that Chris. That might help but my Dropbox is in different places on multiple systems. Its not inside my home folder on any of them, with disk and paths all different. So the Macro’s that sync - the paths that point to the pref .txt file won’t point where I need it to between systems.

There might be away that someone more capable than I can find to work around that, but I’m afraid my coding skills are pretty minimal.

Hey David,

Hmm...

I'd advise you to make the DB folder location uniform amongst your Macs.

If you aren't willing to do that then I'd probably set a KM variable to the DB location on each Mac.

So the DropBoxPath variable might be:

/Dropbox/

Or whatever.

And/or you could have your complete KM_Prefs folder path in a variable and then just use the name of the pref file.

In the macro below I'm using only the Dropbox path, and within the macro I'm adding the subpath to the prefs file:

KM_Prefs/Notes-File Path.txt

Dropbox Path plus Sub-Path.kmmacros (2.1 KB)

This variable substitution works in path fields and when setting a variable to text, so you can make it quite easy to manage the pref files.

-Chris

An easy solution to having the Dropbox path different on each Mac is to use a soft link from a fixed known path. For example, use a softlink from ~/Documents/MyDropbox to the dropbox folder on the local Mac.

Alternatively, as @ccstone suggests, you can set a variable on each Mac with the location of the Dropbox folder on that Mac, and use that variable (and note that this solution would not work if variables were synced).

Alternatively, you can have a sub-macro that gets the path of the dropbox folder on this Mac, perhaps with something like a Switch statement and the %MacName% or %MacUUID% token.

Syncing the variables has a lot of issues with it, not the least being that changes to the variables could affect other macros that are already running in very unexpected and dangerous ways (imagine a macro that is deleting the contents of a folder when the Path variable is changed underneath it).

Thanks Chris - yes that variable for the DB path looks like the best option for me.
I can’t make Dropbox uniform across the Macs unfortunately.
Thanks again - I can make that work!
I’m curious why the variables that sync are a bad idea, or at least an option to make certain ones sync. That would certainly make what I’m trying to do an absolute breeze even for me.

  • Dave

I use a certain goofy method to sync variables… I have a while-logged-in/timed macro which is nothing more than a series of actions that set variable values. When I want to populate identical variables in all three of my Macs, I just update that macro and the next time I get on my other Mac, it will get its variables set right up. Only works when I want a variable in common between all computers, but that often is the case. (e.g. an API key for a web service)

You could probably use the same method to approximate a synchronization of macro values, but you’d need to come up with some clever way to identify where latest changes came from, conflict resolution, and all that boring stuff.

1 Like