Jump to content
JimmyTheSaint

syntax to trigger workflow from Karabiner-Elements json file?

Recommended Posts

In the other thread, @deanishe wrote:

To run an .scpt file:
/usr/bin/osascript /path/to/applescript.scpt
or to run AppleScript:
/usr/bin/osascript -e 'tell application "Alfred 3" to ...'

My script consists of this one "tell" statement:

tell application "Alfred 3" to run trigger "SafariTabs-ext" in workflow "com.my.SearchTabs"

The script works fine when I trigger it from a key_code using this piece of code in my Karabiner-Elements json file:

                                "to": [
                                    {
                                        "shell_command": "/usr/bin/osascript ~/Documents/SafariTabs-my.scpt"
                                    }

Since the scripts I intend to write will all be one-liners, I would rather put the "tell" statement inside the json file rather than call a script. What's the proper K-E json syntax to make that "tell" statement part of the shell_command? I would think that I have to escape the spaces and double quotation marks, but I haven't been able to get it right.

Share this post


Link to post
5 hours ago, JimmyTheSaint said:

I have to escape the spaces and double quotation marks

 

Just the quotation marks. This should be correct:

"shell_command": "/usr/bin/osascript -e 'tell application \"Alfred 3\" to run trigger \"SafariTabs-ext\" in workflow \"com.my.SearchTabs\"'"

 

Edited by deanishe
Add -e to command

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×