Trigger Value is empty when using URL trigger from command line

From the command line I run a command similar to:

open kmtrigger://macro=984A3DBF-5B70-4031-979F-5AD44E3B24A5&value=pizza

When displaying %TriggerValue% in a window, the variable is empty though it should say 'pizza'.

Can anyone suggest a fix to get %TriggerValue% to appropriately capture the value parameter, thanks!

That's a trigger by URL that you're using, so you need to open it in a browser for it to work properly. In other words, just supply

kmtrigger://macro=984A3DBF-5B70-4031-979F-5AD44E3B24A5&value=pizza

to Safari.

If you want to trigger from a command line (shell) then choose that in the trigger drop-down. For example:

1 Like

Because you aren't actually sending the value=pizza part -- & is a special shell character and your command stops there. Try either escaping the & or single-quoting the whole kmtrigger string:
open kmtrigger://macro=URL%20test\&value=pizza
or
open 'kmtrigger://macro=URL%20test&value=pizza'

(This is KM 10.1.1 and macOS 10.13 -- is it just me or does it work for anyone else? I had the same understanding as @tiffle until I tried it just now!)

3 Likes

Well spotted @Nige_S! I spent ages fiddling with the open command and totally missed that; thanks for the lesson :pray:

1 Like

Whoa that works - thank you so much!

I wish https://wiki.keyboardmaestro.com/trigger/URL mentioned that caveat as I spent so much time trying to figure out why it wasn't working :weary:

Many thanks again @Nige_S