启动 Mac 上的应用程序
我需要在启动时运行我的应用程序。因此,当用户启动他的 Mac 并即将看到他的桌面时,我的应用程序需要启动。我将我的应用程序设置为作为 launchd 运行。我在 launchd 进程的 plist 中使用 QueuedDirectories 标志。因此,如果我放置一个文件,它会自动启动。我看过这个问题 - 如何我要在系统启动时启动应用程序吗? (Mac OSX、Cocoa)。建议的答案是使用 launchd。
我有两个问题 -
在存在多个帐户的 Mac 中,该应用程序不会为其他用户(尚未安装该应用程序)启动。在 Windows 中,您可以为每个人安装程序。 Mac 上也可能有类似的事情吗?如果是这样,我可以使用 launchd 的排队目录方法。
launchd 也是在 Lion 中启动/登录时启动应用程序的正确方法。或者苹果是否在 Lion 中添加了任何新功能,这将使这一切能够以更智能的方式完成。我抬头一看,一切似乎都指向 launchd。
我的目标是雪豹和狮子。
I need to run my application on startup. So when the user boot up his Mac and is about to see his desktop, my application needs to launch. I set my app to run as launchd. I am using the QueuedDirectories flag in the plist of the launchd process. So if I place a file it launches up automatically. I have looked at the question - How do I launch an application on system startup? (Mac OSX, Cocoa). The suggested answer is to use launchd.
I have two questions -
In Macs where more than one accounts are present, the application does not launch for the other user(who has not installed it). In Windows you can install program for everyone. Is a similar thing possible on Mac. If so, I can use the Queued directory approach with launchd.
Is launchd the right way to start an application at startup/login in Lion as well. Or has Apple added any new feature with Lion which will allow this to be done in a smarter way. I looked up and everything does seem to point towards launchd.
I am targeting Snow leopard and Lion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您应该使用 launchd。看看我对这个问题。
基本上,您需要在根目录中安装 launchd 配置文件
/Library/LaunchAgents/
文件夹,而不是单个用户的~/Library/LaunchAgents/
文件夹。这样,它将为每个登录的用户启动一个实例。Yes, you should be using launchd. Have a look at my answer to this question.
Basically, you need to install your launchd configuration file in the root
/Library/LaunchAgents/
folder rather than an individual user's~/Library/LaunchAgents/
folder. That way, it will launch an instance for each user that logs in.