Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 47 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save kaloprominat/6111584 to your computer and use it in GitHub Desktop.
Save kaloprominat/6111584 to your computer and use it in GitHub Desktop.
macos: manage add list remove login items apple script
# applescript
# add login item
osascript -e 'tell application "System Events" to make login item at end with properties {name: "Notes",path:"/Applications/Notes.app", hidden:false}'
# delete login item
osascript -e 'tell application "System Events" to delete login item "itemname"'
# list loginitems
osascript -e 'tell application "System Events" to get the name of every login item'
# with defaults
defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '{ "Name" = "Notes" ; "Path" = "/Applications/Notes.app"; "Hide" = 0; }'
@blazejpawlak
Copy link

Does this work for you in Big Sur?

@kaloprominat
Copy link
Author

kaloprominat commented Jun 3, 2021

Does this work for you in Big Sur?

just tried – listing loginitems via apple script works on big sur @ m1 for me

@blazejpawlak
Copy link

Does adding and deleting too?

@lougreenwood
Copy link

Seems it requires an absolute path, I can't add things like ~/some-thing to the login items (it just doesn't appear)

@Tekl
Copy link

Tekl commented Dec 22, 2022

Seems not to work in Ventura anymore to add startup items which launch hidden.

@dnyaneshwarmane
Copy link

not adding as application , only adding as Unix executable

@artginzburg
Copy link

Looks like the defaults write method does not work since Big Sur.

Also, does name: "Notes" in the properties do anything? Seems like path is sufficient, works fine.

@da4ftso
Copy link

da4ftso commented Feb 14, 2024

The delete method does not work on macOS Sonoma 14.3, but list and add do.

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