所有用户的Applescript登录项



使用Applescript如何为所有用户注册登录项?

我知道有一个library/preferences/loginwindow.plist文件保存了这些信息。

我需要在登录时启动safari并导航到URL。这需要为任何登录的用户完成。我一直在寻找启动代理,这似乎是我最好的选择。

我在Library/LaunchAgents/中有以下内容,它在登录时启动safari,但我不知道如何指定URL

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>heymega.safari.launcher</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/Safari.app/Contents/MacOS/Safari</string>
    </array>
</dict>
</plist>

您应该能够将url作为参数:

<string>/Applications/Safari.app/Contents/MacOS/Safari</string>
<string>http://example.com</string>

如果不工作,你可以尝试调用osascript直接Safari到url:

/Applications/Safari.app/Contents/MacOS/Safari & sleep 1 && osascript -e 'tell application "Safari" to open location "http://www.example.com"'

osascript方法使用睡眠,以便Safari在执行之前有机会启动。

最新更新