I just installed a clean 11.2 and the opening elements in login are very random in Login Items windows. Telegram iTerm and Flux does not start. But Notion yes and 1password, karabiner and other not listed in Login Items. I have removed and put back the elements, but no change.
-
Have you confirmed that you can successfully launch these apps manually? – pion Feb 08 '21 at 20:18
-
Yes I can launch these apps succesfully – The33Coder Feb 08 '21 at 20:46
-
@The33Coder, I've the same problem here, have you found a fix? – zakmck May 24 '21 at 09:31
-
I don't find any solution at this time – The33Coder May 28 '21 at 09:20
-
@The33Coder, thanks, I found the workaround below. – zakmck May 29 '21 at 22:17
1 Answers
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.
- 386
