macOS Shortcut Output Expectations

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

macOS Shortcut Output Expectations Sun Dec 19, 2021 12:09 pm • by kubisuro
Hi all,
I've got a Shortcut that successfully takes an input file from Hazel using the new Shortcut action. But I can't get Shortcuts to send the updated file back to Hazel or even have the Shortcut save to the original path. If I try to save the file in Shortcuts it goes to a temporary file in /var and I cannot seem to get it out of that temporary folder. For example, Shortcuts, when used via Hazel, inexplicably runs all actions on:
Code: Select all
/var/folders/0c/80n9c6gd3fzf6dp7d0 ytfk00000gn/I/ryan 2021 12 18 16.20.56.JPG


When I run the Shortcut in Finder via quick actions it works directly on the file. The Shortcut uses exiftool -overwrite_original to add keywords to input JPG. I've also tried using a shell script to launch Shortcuts using
Code: Select all
shortcuts run "..." -i "$1"
and alternatively also adding -o "$1", to no avail.

macOS 12.1 Shortcuts is SO WEIRD and insanely frustrating.

Anyway, are there any tips on getting an output from Shortcuts to Hazel or to avoid that /var/ blackhole? I won't be surprised if I just have to wait for Shortcuts to mature a bit more.
kubisuro
 
Posts: 3
Joined: Sun Sep 20, 2020 10:53 am

Re: macOS Shortcut Output Expectations Mon Dec 20, 2021 9:42 am • by Mr_Noodle
Hazel does not do anything with the output of a Shortcut because it is broken. Depending on the mechanism used, you either get nothing or you get the contents of the file, not the path. So for the moment, Shortcut outputs are not hooked up.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: macOS Shortcut Output Expectations Mon Dec 20, 2021 12:55 pm • by kubisuro
Mr_Noodle wrote:Hazel does not do anything with the output of a Shortcut because it is broken. Depending on the mechanism used, you either get nothing or you get the contents of the file, not the path. So for the moment, Shortcut outputs are not hooked up.


Copy that! That is what I was afraid of. Thank you for the prompt reply.
kubisuro
 
Posts: 3
Joined: Sun Sep 20, 2020 10:53 am

Re: macOS Shortcut Output Expectations Sun Mar 13, 2022 11:13 am • by kubisuro
kubisuro wrote:Anyway, are there any tips on getting an output from Shortcuts to Hazel or to avoid that /var/ blackhole? I won't be surprised if I just have to wait for Shortcuts to mature a bit more.


I got Logger for Shortcuts and immediately understood better what was happening. Turns out when Shortcuts is run in the background by Hazel (and I'm sure by any other app), Shortcut Input gets hijacked and put into a temporary folder (as alluded to above). Even the file paths are hijacked. But the key thing I didn't realize was that ALL FILE OPERATIONS occurs on Shortcut Input. Shortcut Input is NOT immutable and is the file you're actually working on. In this case, anyway. So that means I have to output the Shortcut Input after I'm done working on the file.

Anyway, to get Shortcuts to work in Hazel I need to run an embedded Apple Script so I can save the Shortcut's output:
Code: Select all
do shell script “shortcuts run ’Shortcut Name Modified for use with Hazel’ -i ” & quoted form of POSIX path of theFile & “ -o ” & quoted form of POSIX path of theFile
kubisuro
 
Posts: 3
Joined: Sun Sep 20, 2020 10:53 am

Re: macOS Shortcut Output Expectations Mon Mar 14, 2022 9:39 am • by Mr_Noodle
Thanks for the update. Shortcuts is a bit of a mess so if you are able to use anything else, I'd recommend it for stability reasons.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support