115 points · by msephton · 2y ago · 68 comments
I even built my own Mac app which sits in my menubar syncing tags on project folders with the status of projects in a web app I built. Even better that is synced with iCloud so I can access all of those files and tags from my other devices.
I had not considered how else I could improve this situation with context menu options, but now I want to explore how I could use Automator to improve this setup even more.
One is another engineer, who we kinda laughed over a tendency to spend an insane amount of time automating things that are quick. Like adding a tag to a folder is quick, I just didnt want to do it and things get out of sync.
But he also thought it was really cool and also did not really know about tags until we started talking about this. Kinda like me, he knew they were there but just never did anything with it.
I also showed it to my partner who kinda just keeps laughing every time he sees me glued to my laptop debugging this thing and tweaking it.
It has honestly been a really fun project though. Trying to keep things as native functionality as possible since the entire point of this is to make it so I can more easily work on a script or some other supporting document for a project on my iPad or iPhone and once I get on my Mac everything will just fall into place. I even made it so if I make a folder, it will send the name of that folder to my web app as a new project. (well the web app handles if its new or not, but still).
My only real annoyances so far:
1: Mac doesn't have the ability natively to automatically tag all files in a folder that the tags of the parent folder. I could script this, and I might. But I kinda wish I didn't have too.
2: Why is there no ability in Swift or a Mac app in general to read the contents of a Pages file. Honestly this kinda drives me insane. (I found a workaround by using a github project to turn it into HTML, but that really should not be necessary).
3: I really wish I could make a smart folder that would show me files based on the tags of the parent folder. This way I could have 2 folders in different locations (one that syncs with iCloud and one that syncs with my NAS with very different data, but used in combination) and I could create a smart folder with a single view of all of those files. But this unfortunately seems impossible. (Edit: I guess I could just automatically create symlinks, but a smart folder would be so much cleaner)
> Apply to multiple types (files or directories; can be as granular as file extension)
> Show output (sometimes you want to see the results of the command)
> Confirmation before running (if it’s a potentially dangerous operation)
Nit: The last 2 points are actually possible in Automator
Some examples:
* Remove PDF password: https://www.sheshbabu.com/posts/remove-pdf-passwords-using-q...
* Summarize text with Ollama: https://www.sheshbabu.com/posts/system-wide-text-summarizati...
Workflow receives current "image files" in "any application"
Image = Action
Run shell script:
Shell: /bin/zsh
Pass input: As argument
for f in "$@"
do
/opt/homebrew/bin/exiftool -all= -tagsfromfile @ -ColorSpaceTags -Orientation $f
done
----Will be under the Quick Actions menu.
I tried the same with Shortcuts, but I cannot get it to run from the context menu, only within Shortcuts during testing. Maybe something limiting shell command access from Shortcuts? Not sure.
Step 1 - Receive Images input from Quick Actions
Step 2 - Run same script as above, Shell: zsh, Input: <blank, Shortcuts Input?>, Pass Input: As args
Step 3 - Show Shell Script Result
Very neat, I looked into it briefly and it looks like using {@%.*} is not posix compliant, but a bashism. However the substitution itself is posix compliant, so I may start using something like this in my scripts. Need to look at this more, but this is a heck of a lot less clunky than `echo | sed`... I need to go read `info coreutils` more closely.....
- Search Image (search selected image through google lens)
- Compress Images (compress selected images with jpegoptim or pngquant)
- Open In Terminal / Vim (open selected directory in terminal / selected files in Vim)
- Merge Subtitles (merge .srt subtitles into video files)
Also discovered it's very useful to enable the preview panel in Finder (View -> Show Preview or cmd+shift+p) because it has 3 slots for quick action, much faster than going to context menu.
Also for showing output, you can use
osascript -e "display notification \"Message Here!\" with title \"Title Here!\""
[0] https://github.com/slmjkdbtl/rc/tree/master/shortcuts (shame that the .shortcut files aren't text based like automator files, no easy way to preview)The ones on the blog post appear as services because the take text, but I have others that work on files as Quick Actions.
I wish Swift could replace AppleScript, but that is asking for too much. I dread the day AppleScript is not longer supported. Shortcuts is way too limited in my experience.
convert_file() { f="$1" /opt/homebrew/bin/ffmpeg -i "$f" "${f%.*}.mp4" }
export -f convert_file
parallel convert_file ::: "$@"
Using ContextMenu.app (yes) Automator (no) standard macOS (no)
The key point is it only shows things in the right context: every item can be run on the selection.
Everything except for the last part of this is native functionality built into Mac. Automator is an app every Mac ships with and it natively has the ability to put things in your Quick Actions, make folder actions, etc.
The only real hacky part of this is that it is stuck within the "Quick Actions" menu instead of just being part of the dropdown and this app addresses that. But thats a fairly small part of this implementation.
In MacOS, it is really convoluted. Do I dynamically load some bundle? What bundle? Likely they'll put it somewhere else sometime soon.
Of course in principle, there is some API but the way that Apple treats them is very different.
For example, I want to get how many fingers are touching the trackpad right now and the current position of these touches. There are all sorts of things like PinchControllers that need to be initialized and they emit events etc., but nothing to give you the current state of affairs or exactly what you want.
If you look at the page, the difference between the official implementation and this app is that instead of it being under "Quick Actions" in your context menu, it is just right there.
It isnt like Apple doesn't give you a way to put something in your context menu with Automator, they just put it inside Quick Actions. You don't even need to use Automator, just right click in finder, go to quick actions and click customize.
Would it be great if I didnt need it to be stuck under Quick Actions, I mean sure. But except for one minor change (making something 1 less level deep in a menu) this entire workflow is possible without any third party app or "hacks".
Edit: If we want to talk about API's and other things sure. But given the context of this article, I was assuming that the OP was talking about the functionality presented in this article which most of the implementation is Apple provided tooling.
In macOS, you'd write a Finder Action Extension[0], which lets users add buttons to Finder's toolbar and context menus.
> In Windows, you'd either have something documenting that API (to add it in the context menu, not under Quick Actions)
As someone who uses both Macs and Windows PCs, I absolutely loathe that this is so common in Windows. Every utility I install wants to add their own items to context menus, and they can do so without my permission. On the Mac, users need to opt-in to allowing your extensions, and they can always go to System Settings and disable them later.
[0]https://developer.apple.com/documentation/appkit/app_extensi...
Is using undocumented APIs in Windows common? This sets off my Spidey-sense hard.
That's built-in and doesn't require any setup.
But why do we consider that abandoned? It seems like the kind of thing that if it works, why keep updating it? Now if it broke in a new version of Mac and it wasnt updated, sure we could call it that. But from what I can tell this is not the case.
But that is a really good point, I am curious why both continue to exist except for not wanting to break existing Automator... automations? I am not sure what they are called.
Autommator does still have the major functionality (when it works) of being able to record your actions and just do those. Which shortcuts cannot do.
Apparently you can just convert automator to shortcuts: https://support.apple.com/guide/automator/use-your-workflows...
I would bet that it is the "record" functionality keeping it around (beyond just the "multi-year transition" apple said they were doing in 2021), but maybe there are some other power features that are unavailable in shortcuts yet.
/s