I'm been trying to write a plist file on which when I return from sleep mode, I always want to make my Mac volume to the minimum amount. However, it looks like the following plist doesn't work, with an error: 1:1: syntax error: Expected string but found end of script. (-2741)
<?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>KeepAlive</key>
<false/>
<key>Label</key>
<string>my.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>-e</string>
<string>"</string>
<string>set</string>
<string>volume</string>
<string>output</string>
<string>volume</string>
<string>0</string>
<string>"</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Also, when the following is not working:
<?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>KeepAlive</key>
<false/>
<key>Label</key>
<string>my.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>-e</string>
<string>"set volume output volume 0"</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The osascript
command functions well if I execute it from within Terminal, so I think it's due to how I set my arguments list to the plist.
So is it feasible to take the string argument like "~"
in launchd? Or is there some other things that I'm missing here?
I suspect that it might be better to write the osascript
command in shell script, and load the shell script to enable the Mac's volume to minimize... but is it the correct approach?
I use OS X Mavericks 10.9.2.