- UID
- 2937299
- 最后登录
- 1970-1-1
- 阅读权限
- 30
- 精华
- 主题
- 回帖
- 0
- 积分
- 310
- PB币
-
- 威望
-
- 贡献
-
- 技术
-
- 活跃
-
|

本帖最后由 305451372 于 2023-3-3 13:35 编辑
解决方式是登录后开关一次,夜览和蓝牙原理一样
1. 终端先安装软件
- -- brew install hammerspoon
- -- brew install smudge/smudge/nightlight
- -- brew install blueutil
复制代码
2. 脚本内容
默认位置在 ~/.hammerspoon/init.lua
- function nightlightControl(state)
- print('nightlightControl ', state)
- cmd = "/usr/local/bin/nightlight " .. (state)
- ok, result = hs.osascript.applescript(string.format('do shell script "%s"', cmd))
- return result
- end
- function bluetoothControl(state)
- print('bluetoothControl ', state)
- cmd = "/usr/local/bin/blueutil -p " .. (state)
- ok, result = hs.osascript.applescript(string.format('do shell script "%s"', cmd))
- return result
- end
- function caffeinateCallback(eventType)
- if (eventType == hs.caffeinate.watcher.screensDidUnlock) then
- if (string.match(nightlightControl('status'), 'on')) then
- nightlightControl('off')
- nightlightControl('on')
- end
- if (bluetoothControl('') == '1') then
- bluetoothControl('0')
- bluetoothControl('1')
- end
- end
- end
- caffeinateWatcher = hs.caffeinate.watcher.new(caffeinateCallback)
- caffeinateWatcher:start()
复制代码
OR
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|