带参数的 Mac OS 登录项? [英] Mac OS Login Items with Arguments?

查看:18
本文介绍了带参数的 Mac OS 登录项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Mac OS 中,我创建了一些 AppleScript 来添加和删除启动应用程序(登录项,在帐户"系统窗格下).

In Mac OS, I've created a few AppleScripts to add and remove start up applications (Login Items, under the Accounts system pane).

#!/bin/bash
/usr/bin/osascript -e "tell application \"System Events\" to make new login item with properties { path: \"$1\", hidden:false } at end"

用法如下:

./addloginitem.sh /Applications/TextEdit.app

我很好奇是否有可能使用参数的启动项?我有一个程序,如果它在登录后直接运行,我想将启动"参数传递给它.

I'm curious if it's possible to have startup items that use arguments? I have a program that I would like to pass a "startup" argument to if it is running directly after a login.

推荐答案

这是可能的,但不能通过使用登录项".您可以在登录时使用 launchd 来运行命令.与登录项相比,使用起来有点复杂,但它们更加灵活,可以按照您的要求进行操作.只需在 google 上搜索启动指令,设置所需的 plist 文件,您就会有一个强大的方法在登录时启动.

It is possible however not by using "Login Items". You can use launchd to run commands when you login. It's a little complicated to use compared to login items but they're much more flexible and can do as you request. Just google for launchd instructions, setup the required plist file, and you'd have a powerful method for launching things at login.

这篇关于带参数的 Mac OS 登录项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆