How to use `%WindowName%1%` in shell script?

I am confused. Need it as part of here:

open -g "notchbar:todo?set=$KMVAR_parent - $KMVAR_task"

like so:

open -g "notchbar:todo?set=$WindowName1 - $KMVAR_parent - $KMVAR_task"

Before running an Execute Shell Script action, you can bind a Keyboard Maestro variable name to the result of processing the %WindowName%1% token, and reference that variable name, with a $KMVAR_ prefix, in your shell incantation.

(Token processing is performed over KM text fields, but not over the source text of Execute Shell Script actions)

2 Likes

Another vote for this.

But if you really want to do it in the shell script:

open -g "notchbar:todo?set=$( osascript -e "tell application \"Keyboard Maestro Engine\" to process tokens \"%WindowName%1%\" " )  - $KMVAR_parent - $KMVAR_task"

...might do it.

Tested in a macro containing

open -a Finder "/Users/me/$( osascript -e "tell application \"Keyboard Maestro Engine\" to process tokens \"%WindowName%2%\" " )"

..which successfully switches between the frontmost 2 Finder windows -- so the theory's sound!

2 Likes