设置 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 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s