Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active May 17, 2023 22:41
Show Gist options
  • Save talkingmoose/1215744 to your computer and use it in GitHub Desktop.
Save talkingmoose/1215744 to your computer and use it in GitHub Desktop.
Example: How to launch a GUI application using launchd
<?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>
<true/>
<key>Label</key>
<string>pvt.talkingmoose.LaunchTextEdit</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-a</string>
<string>/System/Applications/TextEdit.app</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
@talkingmoose
Copy link
Author

Paste the above code into a TextEdit window and save it as plain text. Save the file as pvt.talkingmoose.LaunchTextEdit.plist into /Library/LaunchAgents. Log out and log in. TextEdit should open automatically for any user.

@rvarkey
Copy link

rvarkey commented Sep 15, 2022

It is not opening for me. I tried teh same steps.

@talkingmoose
Copy link
Author

talkingmoose commented Sep 16, 2022

@rvarkey, this launch agent plist was written more than 10 years ago. If you’re running it on a Monterey Mac, the path to TextEdit has changed to /System/Applications/TextEdit.app. Other than that, it still works in my testing.

I’ve updated it and included an additional key to keep it running. You can remove the KeepAlive key and value if all you want to do is launch at login.

Also, be sure ownership and permissions on the plist are set to root:wheel 644 after you’ve deployed it.

@rvarkey
Copy link

rvarkey commented Sep 16, 2022

Thanks @talkingmoose changing the path and setting the permissions helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment