macOS 上的全局 LaunchAgent 实现

问题描述

我一直在尝试实现一个可以跨多个用户工作的全局启动代理,但我无法将其完成。它完美地适用于单个用户,但是当切换到其他用户时,启动代理失败并显示 exit code 78 - function not implemented 并且无法理解错误中的任何内容。下面是我的 plist

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.my.company.agent</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/sh</string>
        <string>-c</string>
        <string>/Applications/MyApp.app/Contents/Resources/runscript.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

我已将启动代理置于 /Library/LaunchAgents/com.my.company.agent.plist,当我运行 ls -al /Library/LaunchAgents/com.my.company.agent.plist 时,我得到 -rw-r--r-- 1 root wheel 752 Jan 21 13:27 /Library/LaunchAgents/com.my.company.agent.plist

/Library/LaunchAgents 的权限是 drwxr-xr-x 8 root wheel 256 Jan 21 13:32 /Library/LaunchAgents

我正在使用此命令加载代理 /bin/launchctl load /Library/LaunchAgents/com.my.company.agent.plist

当我运行 ls -al /Applications/MyApp.app/Contents/Resources/runscript.sh 时,我得到 -rwxr-xr-x 1 root wheel 227 Jan 21 13:28 /Applications/MyApp.app/Contents/Resources/runscript.sh

runscript.sh 的内容

#! /bin/sh
osascript <<EOF
tell application "Calendar"
   activate
end tell
EOF

根据其他 stackoverlfow 建议,整个配置看起来不错,并且启动代理在第一个用户上运行良好,但是一旦我尝试从第二个用户加载它,它就会失败并显示 78 退出代码,我非常感谢您的输入,谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...