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 &
I have then created a launch service as ~/Library/LaunchAgents/my_login_items.plist
with the content
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.loginscript</string>
<key>Program</key>
<string>/path/to/login.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
And then run launchctl load ~/Library/LaunchAgents/my_login_items.plist
.
Nothing happens, however.
Best Answer
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 &
in a subshell. I changedlogin.sh
to......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
&
from the end of your command - I'm not convinced this is necessary withlaunchd
, and it was preventing my wrapper script from logging that it had ended (though the&
wasn't the cause of the original problem).