惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
腾讯CDC
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
Engineering at Meta
Engineering at Meta
C
Check Point Blog
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
WordPress大学
WordPress大学
博客园 - 司徒正美

V2EX - Apple

ios 版本更新至 18.7.8 后部分 app 出现无法联网的情况 Codex App 替代全局语音输入 苹果中国官网挂了 Apple 苹果开发者现在被正式盯上了吗,报税通知邮件大家有没有收到? 中国账号开始强制 iCloud 云贵 😊Vibe 了一个给 iOS6 用的 AI 聊天客户端 App 审核 In Review 两周了 请问大佬们现在 iOS 的自签续签都用啥软件?能手机上完成续签操作的? 在京东上买了 iPhone air 14pro, 1t, 18.7.8,电池 81,感觉还能用 2 年 请教巨佬:现在 [4 月 23 日] 这个时间点值得买 iphone17 吗? 受够了 Mac OS 上 Finder 的搜索体验,写了个 macOS 文件搜索工具 ios18.7.8 能更新么 盖世游戏 macOS 太好用了,比 crossover 好多了 14 寸 M5PRO 的 mbp 是不是散热很差呀? 做了个 Menu 小工具,限制 Mac 充电上限,保护电池健康 掐指一算从去年 12 月开始 ai 编程我已经做了 8 个项目,未来希望再发个手机和游戏应用 苹果 macOS 27 将彻底放弃 Intel Mac watch 配对新手机究竟如何恢复最新备份? apple 以旧换新可以叠加 Epp 吗 Mac 如何阻止软件自动更新? 这种港区(HKD)Apple store 礼品卡能不能用于买 iPhone ? Apple 地图规划出了“不存在”的线路 想入 iPad Pro AirPods2 pro 充不上电求助 请问现在 Apple ID 土区注册问题 mac 连接有线音响,看视频总是前几秒没声音 iPhone 16 Pro 玩 LOLM 掉帧咋办? 最近入手的一些 Macbook 分享,购买建议(13 寸 2015 Pro, 13 寸 2020 Pro M1) AirPods2 电池电量不足,大家是否换过?是否有推荐的店铺?
hammerspoon 是如何当我当个合格的舔狗的
jassssper · 2025-09-30 · via V2EX - Apple

1 、痛点: 在 mac 上聊天的时候 iPhone 手机就一直咚咚的响好烦,如果点击顶部把 ”mac 已登录手机通知关闭“ 的话,又会忘了开,导致女神的消息无法及时回复,被 diss 不是一个合格的舔狗,emm...

2 、观察结论: 如果在 mac 上退出微信的话,手机上的 ”mac 已登录手机通知关闭“ 会自动消掉,手机就能收到通知,从而达到无缝衔接的目的。

3 、解决思路: 使用 hammerspoon 实现如下功能: a.每 30 秒检查一次键盘和鼠标动作,如果 120 秒没有动作就退出 mac 微信(注意不能用 killall ,否则 iPhone 那边不知道 mac 上已经退出了) b.当检测到有鼠标和键盘动作后,立即调起微信登录

4 、具体方法: a.下载、安装、打开 hammerspoon ( https://www.hammerspoon.org/) b.打开配置文件写入脚本:

`local idleLimit = 120 -- 120 秒无操作算不活跃 local checkInterval = 30 -- 每 30 秒检查一次 local wechatBundleID = "com.tencent.xinWeChat"

local timer = nil local enabled = true local lastRunning = nil -- 记录上一次运行状态,避免重复日志

-- 判断微信是否运行 local function isWeChatRunning() return hs.application.get(wechatBundleID) ~= nil end

-- 优雅退出微信 local function quitWeChat(reason) local app = hs.application.get(wechatBundleID) if app then app:kill() hs.alert.show("💤 自动退出微信") print("WeChat quit (" .. (reason or "idle") .. ") at " .. os.date()) lastRunning = false end end

-- 启动微信 local function launchWeChat(reason) if not enabled then return end if not isWeChatRunning() then hs.application.launchOrFocusByBundleID(wechatBundleID) hs.alert.show("🚀 启动微信") print("WeChat launched (" .. (reason or "active") .. ") at " .. os.date()) lastRunning = true end end

-- 检查是否该退出 local function checkIdle() if not enabled then return end local idleTime = hs.host.idleTime() local running = isWeChatRunning()

if running ~= lastRunning then
    print("WeChat running=" .. tostring(running) .. " at " .. os.date())
    lastRunning = running
end

if idleTime > idleLimit and running then
    quitWeChat("idle")
end

end

-- 电源事件监听:休眠时退出微信,唤醒后延迟启动 local sleepWatcher = hs.caffeinate.watcher.new(function(eventType) if eventType == hs.caffeinate.watcher.systemWillSleep then quitWeChat("sleep") elseif eventType == hs.caffeinate.watcher.systemDidWake then hs.timer.doAfter(10, function() launchWeChat("wake") end) elseif eventType == hs.caffeinate.watcher.screensDidSleep then quitWeChat("screens sleep") elseif eventType == hs.caffeinate.watcher.screensDidWake then hs.timer.doAfter(5, function() launchWeChat("screens wake") end) end end) sleepWatcher:start()

-- 定时器:负责检测是否要退出 if timer then timer:stop() end timer = hs.timer.doEvery(checkInterval, checkIdle)

-- 事件监听:键盘/鼠标动作 → 立即启动微信 local eventtap = hs.eventtap.new({ hs.eventtap.event.types.keyDown, hs.eventtap.event.types.mouseMoved, hs.eventtap.event.types.leftMouseDown, hs.eventtap.event.types.rightMouseDown }, function(_) launchWeChat("input") return false end) eventtap:start() ` 后记: 1 、在 iPhone 通知栏可设置 1 小时不提醒,今天不提醒,但是这样也是简单粗暴

2 、微信不像企业微信那样可以设置 5min 10min 无活动就恢复通知

在 AI 大爆发的时代,他们把东西做成这样我表示很痛心