折腾啥 头像

消息来源频道

折腾啥

@zhetengsha

频道40,410 位成员公开可见0 人在线

Power Users/Automators 折腾/讨论/分享各种开源工具/脚本/自动化工作流 👥 群组 @zhetengsha_group 📌 资源合集导航 https://t.me/zhetengsha/2 🎁 恰饭推荐 https://t.me/zhetengsha/957 📢 广告投放 @xream Buy ads: https://telega.io/c/zhetengsha feedId:55438372655431680+userId:62307599601855488

成员规模40,410 位成员
在线情况0 人在线
消息总数4,340 条消息
浏览量总数7,753,402 次浏览

在这个频道里搜索消息……

t.me/zhetengsha

使用脚本判断 Surge VPN 状态并重启
macOS 上 Surge VPN 偶尔会断开
此脚本将先尝试重载配置, 然后尝试重启 App
可配合 Keyboard Maestro 自动化在唤醒系统后检测并重启
#! /usr/bin/env bash
# 检查 Surge 连接状态的函数
check_surge_status() {
# 获取 Surge 的网络服务名称
local surge_service=$(networksetup -listallnetworkservices| grep Surge)

# 获取 Surge 的网络服务状态
local surge_status=$(networksetup -showpppoestatus "$surge_service")

if [ "$surge_status" = "connected" ]; then
echo 0
else
echo 1
fi
}
if [ $(check_surge_status) -eq 0 ]; then
echo "✅ Surge 已连接"
else
# echo "❌ Surge 未连接"
echo "🔄 尝试重载配置"
/Applications/Surge.app/Contents/Applications/surge-cli reload
# echo "重载配置完成"
sleep 2
if [ $(check_surge_status) -eq 0 ]; then
echo "✅ Surge 已连接"
else
# echo "❌ Surge 未连接"
echo "🔄 尝试重启 Surge"
/Applications/Surge.app/Contents/Applications/surge-cli stop
open -a Surge
osascript -e 'tell application "Surge" to set visible of its first window to false'
sleep 2
if [ $(check_surge_status) -eq 0 ]; then
echo "✅ Surge 已连接"
else
echo "❌ Surge 未连接"
fi
fi
fi
🤭 macOS 合集 🧐 频道资源合集 😄 恰饭推荐 💬 群组
🥰 #Mac #macOS #App #VPN #Surge