Playing sound with the OS X launcher daemon

I am trying to execute Apple Script from my launchd daemon. My Script only has one line and is listed below.

say "Message From Daemon!"

      

This always fails and throws this "File some object not found" error message.

Any idea why this is happening? The same Script works correctly if I run from xcode (not launching it via launchd) and from any other application that runs in a custom context.

+3


source to share


2 answers


Sound playback using NSSound

depends on window server

, and the daemon is not allowed to connect to the window server.



I accept the same problem with the command say

. (This tool uses the Text-to-Speech Manager to convert the input text to audio speech and either play it through the audio output device selected in the Preferences System, or save it as an AIFF file.)

+1


source


I assume that you are facing the same problem that I faced when I tried the same. The path in your .plist file should point deeper into the applescript app. Below is an example .plist file.



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.namespace.script_name</string>
        <key>Program</key>
        <string>/Applications/script_name.app/Contents/MacOS/applet</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>1</integer>
        <key>StartInterval</key>
        <integer>7200</integer>
    </dict>
</plist>

      

0


source







All Articles