No internet connection
  1. Home
  2. Script Sharing

Is this worth turning into a package?

By James Richmond @James_Richmond
    2026-03-24 20:06:49.089Z

    Hi folks,

    I've written a script for Soundflow that allows you to trigger Apple Shortcuts on a Mac.
    This then allows you to create scenes in Apple Home that are triggered by the shortcut.

    I've used it to create an automatic "Recording" light for my studio so that whenever Pro Tools goes into record the light turns on and then it stops recording it goes off.

    I didn't want to just turn it into a package without asking first, because it requires other configuration for it to work.

    I’ve written a full tutorial and provided the JavaScript here:

    https://tinyurl.com/recordinglight

    If this is classed as spam then please delete- although I'm not selling anything here. You can just implement it yourself from the tutorial.

    Thanks,

    James Richmond

    • 3 replies
    1. Chad Wahlbrink @Chad2026-03-24 20:45:21.043Z

      Thanks for this, @James_Richmond!

      I think it's probably best to leave this as a tutorial on your personal website since you wouldn't be able to store the Apple Shortcuts with your package on the Store.

      This is a great little workflow, though, and I'm glad you found that SoundFlow helped you accomplish it!

      If it's okay with you, I can move this to the Script Sharing section of the forum for now.


      Note that your script currently uses a while(true) loop, which will block other SoundFlow actions while it's running. You can use a "runforever" script instead, which can run in the background, allowing SoundFlow to run other scripts.
      Example: Select Track as trigger #post-7

      Here's the updated script - untested but should hopefully work:

      if (sf.ui.useSfx && !globalState.OPP_disableSfx) sf.ui.useSfx();
      
      function main() {
          try {
              if (!sf.ui.proTools.isRunning) {
                  if (globalState.wasRecording) {
                      sf.system.execShortcut({
                          shortcutName: 'Recording Light Off'
                      });
                      globalState.wasRecording = false;
                  }
              } else {
                  const recordButton = sf.ui.proTools.mainWindow.transportViewCluster.transportButtons.buttons.whoseTitle.is('Record Enable').first;
                  const buttonValue = recordButton.value.invalidate().value || "";
                  const isRecording = buttonValue.includes("Is Recording");
      
                  if (isRecording && !globalState.wasRecording) {
                      sf.system.execShortcut({
                          shortcutName: "Recording Light On"
                      });
                  }
      
                  if (!isRecording && globalState.wasRecording) {
                      sf.system.execShortcut({
                          shortcutName: "Recording Light Off"
                      });
                  }
      
                  globalState.wasRecording = isRecording;
              }
          } catch (err) {
              // optional: log("Watcher error: " + err);
          }
      }
      
      function runForever(name, action, interval, timeout) {
          var now = (new Date).valueOf();
          if (now - globalState[name] < timeout) throw 0; // Exit if we were invoked again inside the timeout
      
          globalState[name] = now;
          sf.engine.runInBackground(function () {
              try {
                  while (true) {
                      sf.engine.checkForCancellation();
                      globalState[name] = (new Date).valueOf();
      
                      action();
      
                      sf.wait({ intervalMs: interval, executionMode: 'Background' });
                  }
              } finally {
                  globalState[name] = null;
              }
          });
      }
      
      runForever("isRecordingLightRunning", main, 250, 5000);
      
      1. In reply toJames_Richmond:
        James Richmond @James_Richmond
          2026-03-24 20:51:04.082Z

          Thank you for your alteration to the script, and for moving it to the right place.

          I've updated my article with the changes.

          1. Chad Wahlbrink @Chad2026-03-24 22:40:22.289Z

            No problem, @James_Richmond