Login Items does not start in 11.2
Solution 1:
I gave up trying to fix it using the UI. Instead, I've created a launchd agent in ~/Library/LaunchAgents/
. This can be done by writing a .plist
file with this content:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is ~/Library/LaunchAgents/my-login.plist -->
<!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>my-login.agent</string>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>ProgramArguments</key>
<array>
<string>/Users/$myuser/.local/etc/scripts/my-login.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>AbandonProcessGroup</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/my-login.err</string>
<key>StandardOutPath</key>
<string>/tmp/my-login.out</string>
</dict>
</plist>
As you can see, it runs a script in .local/etc/scripts
. In turn, this just runs everything it finds in .local/etc/scripts/login/
(you can choose another dir for this, eg, Library/scripts
):
#!/usr/local/bin/bash
# This is my-login.sh
cd `dirname "$0"`/login
for script in *.sh
do
. "./$script"
done
Finally, login/*.sh
files usually contain very simple commands, eg:
# google-drive-client.sh
open "/Applications/Backup and Sync.app"
(and of course, this is the same mechanism that many *NIX distro use for /etc/profile.d
or /etc/cron.d
).
Everything can be enabled by running:
launchctl load ~/Library/LaunchAgents/my-login.plist
(or, logging off and logging on again should do it too).
The .plist
RunAtLoad
option runs the script upon load, and only once. Moreover, AbandonProcessGroup
ensures that the applications launched in the background (eg, using open
) are not killed when the main script ends.
This isn't for the non-expert, sorry, I couldn't fix the problem at UI level and I think the macOS quality is getting worse.