Why does my launchd script not run at login? I have tried to follow this question so that at login, the currently configured screensaver becomes the desktop background. Therefore, I have created the following script:

# login.sh
/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &amp;


I have then created a launch service as ~/Library/LaunchAgents/my_login_items.plist with the content

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
   &lt;key&gt;Label&lt;/key&gt;
   &lt;string&gt;com.user.loginscript&lt;/string&gt;
   &lt;key&gt;Program&lt;/key&gt;
   &lt;string&gt;/path/to/login.sh&lt;/string&gt;
   &lt;key&gt;RunAtLoad&lt;/key&gt;
   &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


And then run launchctl load ~/Library/LaunchAgents/my_login_items.plist.
Nothing happens, however.
This is a deeply unsatisfying answer, but I got it to work by running /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &amp; in a subshell. I changed login.sh to...

#!/bin/bash
longname=$0
shortname=$(basename "${longname}")
echo "$(date -u "+%Y-%m-%d %H:%M:%S") ${shortname} (${longname}) running..."
output=$(/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background)    # &lt;- COMMAND GOES HERE            
echo "$(date -u "+%Y-%m-%d %H:%M:%S") ${shortname} ended."


...and that works (my usual static desktop changes to my default screensaver). I use this idiom for other launchd tasks, running the tasks in a subshell so I can easily test whether the operation succeeded and log $output. I don't understand why this works while your original doesn't, but at least it does work.

Note that I removed the &amp; from the end of your command - I'm not convinced this is necessary with launchd, and it was preventing my wrapper script from logging that it had ended (though the &amp; wasn't the cause of the original problem).