app • macOS Automator - martindubenet/wed-dev-design GitHub Wiki

Otto the Automator Set-up Automator for custom Quick Actions

Generic setup shared by my Finder Quick Actions (watermarkImg, addDateImg, renameForServer): each one is a Python script called by an Automator Quick Action, plus a small native SwiftUI app (built locally) that only shows its window and posts the end-of-task notification.

Python libraries for Automator's python3

Automator runs the exact interpreter written in the Quick Action (/opt/homebrew/bin/python3), so install the libraries for that one. A plain pip3 may target a different Python.

/opt/homebrew/bin/python3 -m pip install -U Pillow pillow-heif
/opt/homebrew/bin/python3 -c "import sys, PIL; from PIL import features; print(sys.version.split()[0], PIL.__version__, 'AVIF:', features.check('avif'))"
  • pillow-heif usually ships its own libheif. If the install tries to build from source and fails: brew install libheif, then the pip command again.
  • Image tools from Homebrew used by the scripts: brew install librsvg (provides rsvg-convert, for SVG), brew install exiftool (to inspect metadata).

Xcode Command Line Tools (to build the native apps)

xcode-select -p        # prints a path when installed
swiftc --version
xcode-select --install # if missing

Each script folder has a build_app.sh that compiles its <Name>App/main.swift into <Name>.app and signs it ad hoc (enough for a locally built app, macOS doesn't block it). Run it again after any change to the Swift source or after a macOS update if the app misbehaves. The .app is git-ignored.

Scripts on the external drive (usbgT7)

⚠ « usbgT7 » is my personal external USB drive. Skip this if the scripts are on the main drive.

The scripts live in /Volumes/usbgT7/aiScripts/. Automator needs an absolute path and doesn't load my .zshrc aliases (e.g. cdscript, which only works in an interactive Terminal), so one symbolic link covers every script folder:

ln -s /Volumes/usbgT7/aiScripts ~/aiScripts

If the drive is unplugged, the link stays but is broken until the drive is back.

Create a Quick Action

  1. Open Automator → File › New → Quick Action.
  2. At the top of the document:
    • Workflow receives current → image files (or files or folders to accept any file type)
    • in → Finder
    • Image (optional) → an icon from the list, or Choose… for your own (square PNG)
  3. Drag the Run Shell Script action to the right, then set Shell → /bin/zsh and Pass input → as arguments.
  4. Script box: /opt/homebrew/bin/python3 "$HOME/aiScripts/<folder>/<script>.py" "$@"
  5. File › Save with a clear name: that name is the one shown in the Finder's right-click menu.

Quick Actions are saved in ~/Library/Services/. To edit one: in Automator, Open an Existing Document…, press Cmd+Shift+G, type ~/Library/Services, pick the .workflow file. Renaming the .workflow file in the Finder renames the menu item.

Permissions

  • Automation › Finder: some dialogs are shown by the Finder (tell application (path to frontmost application)) so they get the focus. If macOS asks whether Automator / WorkflowServiceRunner may control the Finder, click Allow. Review in System Settings › Privacy & Security › Automation.
  • Notifications: each app asks once whether it may send notifications: click Allow. In System Settings › Notifications › <app name>, keep Desktop checked and Alert Style on Temporary (banners that slide away).

Notifications don't show up as banners

  • A Focus mode is on (Do Not Disturb, Sleep, Personal, Reduce Interruptions…): notifications still arrive, but only in Notification Centre. Check the Focus tile in Control Centre. A Focus turned on on the iPhone also applies to the Mac when Settings › Focus › Share Across Devices is on. To let the scripts through anyway: add their apps in the Focus' Allowed Notifications › Apps.
  • The screen is shared or mirrored (screen recording, video call, AirPlay mirroring): enable System Settings › Notifications › Allow notifications when mirroring or sharing the display.
  • AppleScript's display notification is attributed to Script Editor (clicking it opens Script Editor), which is why the scripts post notifications from their own app instead.

Troubleshooting

  • No dialog appears at all → check that Pass input is as arguments, not "to stdin".
  • Finder alert "The action "Run Shell Script" encountered an error" → unexpected error: run the same command in the Terminal, with a real file path instead of "$@", to see the details.
  • The Quick Action doesn't appear in the menu → enable it in System Settings › Keyboard › Keyboard Shortcuts › Services, then relaunch the Finder (Option+right-click on its Dock icon → Relaunch).
  • Clicks get lost in a script's file chooser (seen since macOS 27.2) → a dialog opened by a background osascript launched from the Finder may not get the focus. Have the frontmost app show it, or use a native app launched with open -W.
⚠️ **GitHub.com Fallback** ⚠️