Services – Quick Actions (Automator)

Service (older) Quick Action (newer): A workflow that you can add to Finder windows, the Touch Bar, and the Services menu. For more information about using Quick Action workflows, see Use Quick Action workflows on Mac.

 

See also MacDev! MacOS! Development (jandp.biz/is/dev/sw/macdev/) for important notes around problems around Security.

Services, Workflows – Automator-based (macOS)

Common pattern

In many cases, start with writing a shell script / command line interface (CLI) tool/executable, then create some small wrapper code for GUI use in applications / Finder.

I.e.

  1. Implement core functionality in CLI tool, e.g. mime-tool-by-j.sh
    1. That can be used in terminal – gred for both development, using flags for verbose outputs, et c, as well as actual use when anyway down there in terminal windows.
    2. Save such in $HOME/bin/ (a subdirectory I’ve had a habit to alway have since maybe around early 1990s on every computer worked with)
  2. Wrapper: as appropriately.
    Creating a Quick Action in Automator app, e.g. Save Web as mhtml J

    1. Quick Action to make tool available via
      1. <App> menu under Services> submenu
      2. As applicable (depending on functionality, how tool has been implemented) possibly in
        1. Finder’s popup menu under Quick Actions, OR
        2. Finder’s popup menu under Services
          which depend on generation of macOS….. NOT the best solution and Apple should fix this….!!!
    2. Most often writing most of code in AppleScript but it happens using other means like bash
    3. Tool that in turn call CLI utility, e.g. mime-tool-by-j.sh

Gotchas / Issues

  1. General: Often start a new script/tool based on some existing, AND OLD code for copied tool may still be around, which can be confusing… NOTE: most scripts created are ONLY intended for my personal use.
    1. And in many cases lots of Work In Progress until a more stable set of pieces works well.
    2. Time that can be months, as lots of work is done when get focus for some period.
  2.  CLI-tools
    1. Such may be using commands that are not standard macOS but downloaded in various ways over many years and lost track if standard or added by myself, and also where such may be stored
    2. via applications (code within apps that are ‘re-usable’ / can be used via CLI/scripts)
    3. brew … (and other download managers)
    4. python ecosystem – yeah…. that also happens, and opens up THAT area of quagmire.
  3. AppleScript: keystrokes (e.g. of areas of issues)
    1. Controlling applications via AppleScript can be really messy when get into some more advanced things like controlling dialogs.
    2. Must give apps rights via System Settings > security … (don’t remember exactly what to do where just now….)

That’s it for now – more a starting point of potential issues.

 

EoP