No internet connection
  1. Home
  2. How to

Trigger SoundFlow command from Apple Automator with Variable?

By Nathan Salefski @nathansalefski
    2024-04-24 00:44:53.047Z

    What's up everyone!

    I was looking for a way to start integrating Automator Applications in order to make one-off tasks a bit more accesible than they currently are -- being several pages deep on my StreamDeck. I see here (https://help.soundflow.org/en/articles/5638030-soundflow-cli) you can trigger SoundFlow commands from the command line however it doesn't note if it's possible to send a variable through to said SoundFlow command. I also don't seem to have the /usr/local/bin/soundflow and am not sure how to install it as it didn't appear after re-installing SoundFlow.

    Any help would be great!

    Thanks!

    Nathan

    • 21 replies

    There are 21 replies. Estimated reading time: 8 minutes

    1. In reply tonathansalefski:
      Dustin Harris @Dustin_Harris
        2024-04-24 03:13:43.805Z

        Check this post out, you can use Automator to run the desired command in terminal.

        1. Nathan Salefski @nathansalefski
            2024-04-24 05:34:41.412Z

            Amazing. I'll give it a shot. Any clue why I'd be missing the /usr/local/bin/soundflow though? I've tried reinstalling but perhaps I need to try a clean install

            1. Dustin Harris @Dustin_Harris
                2024-04-24 11:40:42.534Z

                Not sure… I haven’t done the SoundFlow install location deep dive… what do you need it for?

                1. Nathan Salefski @nathansalefski
                    2024-04-24 14:19:37.114Z

                    Without that specific pathway defined in Automator, Automator cannot run the SoundFlow command via the CLI

                    1. Dustin Harris @Dustin_Harris
                        2024-04-24 14:28:19.620Z

                        You should be able to use Automator to run a shell script or AppleScript, each of which can contain terminal commands to run the soundflow script, and is probably the preferred method anyway.

                        My implementation is a little different here as I’m running applescript from inside SoundFlow, but might be handy for reference:

                2. In reply tonathansalefski:
                  Kitch Membery @Kitch2024-04-24 17:18:29.193Z

                  Hi @nathansalefski,

                  What specifically are you trying to achieve with Automator?

                  1. Nathan Salefski @nathansalefski
                      2024-04-24 17:36:51.384Z

                      It’s fairly simple. You can make “Apps” with the Automator. I’d like to have an app on my dock that I can drag folders onto and the app passes that array along to my existing session prep script

                      1. Kitch Membery @Kitch2024-04-24 17:39:43.355Z

                        What information about the folders are you wanting to be passed along?

                        The file paths inside the folder?

                        1. Nathan Salefski @nathansalefski
                            2024-04-24 17:52:10.715Z

                            The folder pathways themselves. SoundFlow is searching those folders for WAVs and MP3s then creating a session from my template and importing the files from each of the selected folders

                            1. Kitch Membery @Kitch2024-04-24 17:59:54.182Z

                              An approach you could use for this without the need for Automator, could be done as follows.

                              Select a folder in the finder and run the following script.

                              // Get all files recursively from the selected directory in the finder.
                              const folderFilePaths = sf.file.directoryGetFiles({
                                  path: sf.ui.finder.firstSelectedPath,
                                  isRecursive: true,
                              }).paths
                              
                              // Filter .wav files
                              const wavFilePaths = folderFilePaths.filter(path => path.endsWith(".wav"));
                              
                              log(wavFilePaths);
                              
                              1. Nathan Salefski @nathansalefski
                                  2024-04-24 18:17:54.610Z

                                  Yea i've got it working fine opening finder and then calling the command I just wanted to save menu diving for the button and just drag the folders onto the icon instead. Seems more trouble than it's worth though but thanks!

                                  1. Kitch Membery @Kitch2024-04-24 18:58:06.047Z

                                    No worries. And yes I see what you mean.

                                    Be sure to request this functionality in the ideas section of the forum, so it can be considered for future SoundFlow updates.

                                    1. Nathan Salefski @nathansalefski
                                        2024-04-24 20:51:15.659Z

                                        @Dustin_Harris helped me with the how. The issue I'm running into is the Automator isn't detecting the SoundFlow CLI. In the picture in the original post you can see you can choose pathways for the ShellScript to reference but the /usr/local/bin/soundflow that's neccesary (as stated here https://help.soundflow.org/en/articles/5638030-soundflow-cli) isn't an option for me to choose. Running a simple script from terminal works fine though which means it exists on my computer, just seems like Automator cannot reference it. Very stange issue on my end or with Automator itself. I'll be sure to post it as an idea

                                        1. Dustin Harris @Dustin_Harris
                                            2024-04-24 20:54:48.765Z

                                            in automator you can add the action 'run shell script' and then trigger the soundflow CLI from there I believe..

                                            1. Chris Shaw @Chris_Shaw2024-04-25 01:20:13.494Z2024-04-25 03:40:45.449Z

                                              You don't need automator to get the folder paths either. When you drag folders onto a app in the dock the folders remain selected in the Finder so you can grab their paths within the SF script itself.
                                              The only thing automator needs to do is run the SF command via a simple shell / terminal script

                                              1. Kitch Membery @Kitch2024-04-25 01:22:06.028Z

                                                Brilliant!!

                                            2. In reply tonathansalefski:
                                              Kitch Membery @Kitch2024-04-25 01:57:00.596Z

                                              Did you try the full path...

                                              /usr/local/bin/soundflow soundflow run user: <COMMAND ID HERE>
                                              
                                              1. Nathan Salefski @nathansalefski
                                                  2024-04-25 02:20:12.007Z

                                                  Yes when I do so a cog wheel appears briefly in the menu bar and nothing happens. Using just soundflow run user: <COMMAND ID HERE> results in this error:

                                                  1. Kitch Membery @Kitch2024-04-25 03:11:42.343Z

                                                    Try these steps.

                                                    • Create a Script in SoundFlow
                                                    const {arg1, arg2} = event.arguments;
                                                    
                                                    log(arg1)
                                                    log(arg2)
                                                    
                                                    • Use the following command line in your Automator app and replace the command ID with the SoundFlow Scripts ID.
                                                    /usr/local/bin/soundflow run user:xxxxxxxxxxxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxx '{ "arg1": "Arg 1 from Automator","arg2": "Arg 2 from Automator", }'
                                                    
                                                    • Double-click the app or drag a file onto it.

                                                    What happens?

                                                    The argument values should be logged.
                                                    Let me know if that works for you.

                                                    1. Nathan Salefski @nathansalefski
                                                        2024-04-25 03:40:23.046Z

                                                        Finally! I'm not exactly sure what issue I was running into but that seemed to work. I know that Chris mentioned not needing to pass arguments becuase the folders would be highlighted in Finder but what if I drag them from another app, Like Samply for example? I think it would be great to be able to pass the input on through to SoundFlow rather than relying on Finder being in the foreground. I don't know how to do that though lol