设置 VPN 自启动及断线自动连接

两年前的东西了,要不是现在 GFW 这么牛逼估计一辈子都用不到。

新建 AppleScript,贴入代码:

on idle
    tell application "System Events"
        tell current location of network preferences
            set myConnection to the service "YOUR VPN NAME"
            if myConnection is not null then
                if current configuration of myConnection is not connected then
                    connect myConnection
                end if
            end if
        end tell
        return TIME
    end tell
end idle

在第四行的 YOUR VPN NAME 中键入你要连接的VPN名称,在倒数第三行的 TIME 中键入检测时间,例如五秒就是 5

保存为应用程序,并勾选运行处理程序后保持打开

由于这个 AppleScript 应用会一直在你的 dock 上显示,默认图标太丑了,我给换了一个图标:

vpn

这样看上去就好多了。

方法出处:Getting VPN to auto-reconnect on connection drop

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 注销 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s