Page 1 of 1

Example of using JavaScript to return data to the Hazel Rule

PostPosted: Tue Aug 19, 2025 10:50 pm
by halloleo
How can I return data to the Hazel Rule using an JavaScript in the "Passes JavaScript"?

At the moment I use AppleScript:

Code: Select all
set shellOut to do shell script shellCmd
if shellOut is not equal to "" then
   set theRes to {hazelPassesScript:true, hazelOutputAttributes:{shellOut}}
else
   set theRes to {hazelPassesScript:false}
end if

(where shellCmd contains a shell command I want to execute).

I want to moves this to Javascript. Have can I do it?

Thanks for pointers!

Re: Example of using JavaScript to return data to the Hazel

PostPosted: Wed Aug 20, 2025 8:52 am
by Mr_Noodle
Check the manual. There are details and examples there.

Re: Example of using JavaScript to return data to the Hazel

PostPosted: Wed Aug 20, 2025 11:08 pm
by halloleo
Thanks for chiming in, but I could not find a JavaScript example: Under "Using AppleScript or JavaScript " -> "Returning a record" I find only a AppleScript example. (Maybe I have "tomatoes on my eyes" though...)

Re: Example of using JavaScript to return data to the Hazel

PostPosted: Thu Aug 21, 2025 8:41 am
by Mr_Noodle
I believe the syntax is actually the same in this case.