hammerspoon

In Hammerspoon, how to open an app and pass in startup params


I'm trying to make a Hammerspoon hotkey to open and start a daily meeting in Google Meet.

Since I have more than 1 google profile, I need to pass the desired profile in to Chrome at invoke time, using Chrome command-line parameters.

The normal Hammerspoon app launch methods all fail when adding these extra parameters in the launch string.

More specifically, the following works from the command line and has the effect that I want: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --app=https://meet.google.com/some-meeting-id --profile-directory='Profile 1'

But using that string inside of hs.application.open, hs.application.launchOrFocus, or hs.urlevent.openURL all fail.

How to get Hammerspoon to open an app startup command that includes extra parameters like this?


Solution

  • I came up with a decent workaround:

    I bundled the long command line with arguments inside an AppleScript using do shell script, and then saved it as an Application (e.g., StartMeetup.app). After that, Hammerspoon is able to launch with:

    hs.application.open("StartMeetup")
    

    However, it would still be very useful to know how to get Hammerspoon to do this directly, without the intermediary script.