Is it possible to set a KM Variable with a Shell Script

And similarly:

#!/bin/bash

varName="someTempVar"
varValue="some temp val like 42"

osascript -l JavaScript -e "function run(argv) \
{Application('Keyboard Maestro Engine') \
.setvariable('$varName', {to:'$varValue'})}"

for:

or perhaps more flexibly:

#!/bin/bash


# Two quoted arguments: KMVarName KMVarValue
setKMVar() {
    osascript -l JavaScript -e "function run(argv) \
    {Application('Keyboard Maestro Engine') \
    .setvariable('$1', {to:'$2'})}"
}


setKMVar "someName" "some string value"

3 Likes