I am brand new to AppleScript, and since it seems to be the quickest way to input a parameter into an Hazel rule, I am experimenting a bit and found a blocking issue.
I would like to use the same rule, synced via Dropbox, on two separate machines, and add the hostname to the screenshots generated on both machines.
As there doesn't seem to be a way to tell the hostname within Hazel, AppleScript seemed the easiest way to proceed.
I have read the documentation at:
https://www.noodlesoft.com/manual/hazel ... avascript/
and found that with something like this, things should work:
set hostname to computer name of (system info)
return {hazelPassesScript:true, hazelOutputAttributes:hostname}
This is how I have configured the script in Hazel:

But Hazel doesn't like something in there, and here is the error message from the log:
- Code: Select all
2020-10-07 10:18:55.532 hazelworker[64657] Invalid type given for hazelOutputAttributes key returned from script.
2020-10-07 10:18:55.533 hazelworker[64657] [Error] Error during rule evaluation: Received error while trying to evaluate rule Screenshots via macOS on file Screenshot 2020-10-07 at 10.09.27.png
2020-10-07 10:18:55.533 hazelworker[64657] Error while matching rule Screenshots via macOS against file /Users/luca/Downloads/Screenshot 2020-10-07 at 10.09.27.png: Invalid AppleScript return value: hazelOutputAttributes.
2020-10-07 10:18:55.533 hazelworker[64657] ###main load address: 0x100c2d000
2020-10-07 10:18:55.533 hazelworker[64657] ###Noodle load address: 0x100d4f000
2020-10-07 10:18:55.533 hazelworker[64657] ###CK load address: 0x100d14000
2020-10-07 10:18:55.533 hazelworker[64657] (
0 CoreFoundation 0x00007fff3037e727 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff69286a9e objc_exception_throw + 48
2 hazelworker 0x0000000100c6b6a8 hazelworker + 255656
3 Foundation 0x00007fff329c673d -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 293
4 hazelworker 0x0000000100ca41aa hazelworker + 487850
5 hazelworker 0x0000000100ca854a hazelworker + 505162
6 hazelworker 0x0000000100ca86f2 hazelworker + 505586
7 hazelworker 0x0000000100ca689b hazelworker + 497819
8 hazelworker 0x0000000100cb2b9c hazelworker + 547740
9 hazelworker 0x0000000100c7524d hazelworker + 295501
10 hazelworker 0x0000000100c34a40 hazelworker + 31296
11 hazelworker 0x0000000100c37b8a hazelworker + 43914
12 hazelworker 0x0000000100c39dbf hazelworker + 52671
13 libdyld.dylib 0x00007fff6a426cc9 start + 1
)
Where did I not understand how returning values from AppleScript back into Hazel works?
Please note that the core of the script works well into the Script Editor, so the issue is purely into the way Hazel interacts with the script.
Any help is much appreciated!
Thanks,
Luca