Programmatically run at startup on Mac OS X?

前端 未结 4 1835
悲哀的现实
悲哀的现实 2020-12-07 21:09

How do I programmatically set an application bundle on Mac OS X to run when the user logs in?

Basically, the equivalent of the HKCU\\Software\\Microsoft\\Windo

4条回答
  •  遥遥无期
    2020-12-07 21:52

    A working example below.

    Create a file

    ~/Library/LaunchAgents/my.everydaytasks.plist

    With contents:

    
    
    
    
        Label
        my.everydaytasks
        ProgramArguments
        
            /Applications/EverydayTasks.app/Contents/MacOS/EverydayTasks
        
        ProcessType
        Interactive
        RunAtLoad
        
        KeepAlive
        
    
    
    

    See the original post that helped me to make this example:

    https://superuser.com/a/229792/43997

    To test you need to run this in terminal

    launchctl load -w ~/Library/LaunchAgents/my.everydaytasks.plist
    

    To unload

    launchctl unload -w ~/Library/LaunchAgents/my.everydaytasks.plist
    

    See also

    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html

    The is the other way of adding your application to starup using "Login Items". See this example project on how to implement it:

    https://github.com/justin/Shared-File-List-Example

提交回复
热议问题