Skip to content

Instantly share code, notes, and snippets.

@nweddle
Last active September 22, 2022 23:32
Show Gist options
  • Save nweddle/e8cece424a8c8c1e121ad33922dc7dd0 to your computer and use it in GitHub Desktop.
Save nweddle/e8cece424a8c8c1e121ad33922dc7dd0 to your computer and use it in GitHub Desktop.
macOS Login items via Apple Script
# https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html
# https://stackoverflow.com/a/69404641
# Using Apple Script
# list loginitems
osascript -e 'tell application "System Events" to get the name of every login item'
# list details of login items
osascript -e 'tell application "System Events" to get the properties of every login item'
# output
# {{name:"EVO", path:"/Applications/EVO.app", class:login item, kind:"Application", hidden:false},
# {name:"Cron", path:"/Applications/Cron.app", class:login item, kind:"Application", hidden:true}}
# add login item
osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/MyAppName.app", hidden:false}'
# delete login item
osascript -e 'tell application "System Events" to delete login item "MyAppName"'
# Using `defaults` CLI
defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '{ "Name" = "Notes" ; "Path" = "/Applications/Notes.app"; "Hide" = 0; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment