参考链接
问题定位
- 问题总结如下:
- touchbar 闪烁出现在其未被激活使用的时候
- touchbar 闪烁是随机发生的
- touchbar 闪烁也出现在安全模式
- 重置 SMC 或 NVRAM 无济于事
- 重新安装 MacOS 没有帮助
- 这是一个硬件问题,如果 MacBook 不在保修范围内,维修代价高昂,并不值得
- 核心思想
- 因为触控栏在活动时不会闪烁,所以不断激活触控栏使其处于活动状态是修复touchbar闪烁的关键,此修复程序只做一件事:它使 TouchBar 保持活动状态,因此它不会关闭。准确地说,每当touchbar即将关闭时此程序都会重新启动 TouchBar。
- 因为触控栏在活动时不会闪烁,所以不断激活触控栏使其处于活动状态是修复touchbar闪烁的关键,此修复程序只做一件事:它使 TouchBar 保持活动状态,因此它不会关闭。准确地说,每当touchbar即将关闭时此程序都会重新启动 TouchBar。
脚本
-
脚本程序已在 MacBook Pro 15 英寸 2019 和 MacOS Monterey 12.1 上进行了测试,并没有任何问题
设置键盘
- 在继续之前,请确保您的键盘设置和我保持一致。
- 重要的是关闭键盘背光,将其设置为至少 1 分钟。
软件
- 从苹果商店下载软件,软件的名字如下,JSON Helper
- 打开上述软件,并黏贴代码
- 注意事项:切记要替换下面代码中的字段
YourUserNameGoesThere和
YourPasswordGoesThere,且每个字段均替换了两次
global computerIsInUse, resetTime
on run
set computerIsInUse to true
set resetTime to (do shell script "date +%s") as integer
end run
on idle
set idleTime to (do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF; exit}'") as integer
if idleTime is greater than 7.4E+10 then
if computerIsInUse then
do shell script "pkill TouchBarServer" user name "YourUserNameGoesThere" password "YourPasswordGoesThere" with administrator privileges
set computerIsInUse to false
end if
end if
if idleTime is less than 7.4E+10 then
set computerIsInUse to true
end if
set now to (do shell script "date +%s") as integer
if (not computerIsInUse) and ((now - resetTime) is greater than 59) then
do shell script "pkill TouchBarServer" user name "YourUserNameGoesThere" password "YourPasswordGoesThere" with administrator privileges
set resetTime to (do shell script "date +%s") as integer
end if
return 1
end idle
脚本的作用:
- 在第 9 行,程序检查您未使用计算机的时间:
idleTime
- 因为 TouchBar 大约在 75 秒后完全关闭,所以它会检查
idleTime
是在 74 秒之前还是之后:7.4E+10。 - 如果
idleTime
经过这 75 秒,它会重新启动 TouchBar 并设置computerIsInUse
为 false,因为您显然没有使用计算机(不是按键或鼠标等)。 - 如果
computerIsInUse
为假(仅在 75 秒后发生),它将立即重新启动 TouchBar,然后每 60 秒(超过 59 秒)重新启动。为什么?因为如果没有,你的 Touchbar 会在 60 秒后消失。该脚本必须每 60 秒重新启动一次。
注释:当 TouchBar 在前 60 秒后稍微变暗并保持稍微变暗约 15 秒(第一次重启发生在 7.4E+10 之后的原因)时,您可以在这 15 秒内体验到闪烁应用。这些是更新 Touchbar 中数据的应用程序,例如 IINA。如果您遇到这种情况,只需将 7.4E+10 更改为 5.9E+10。
创建应用
- 现在可以将脚本导出为应用程序。
- 选择File -> Export并创建最终应用程序:
- 请参见下面的屏幕截图。
- 找到桌面的程序,右键打开即可发挥应用的作用
- 使用活动监视器可以看到新建的程序
注意事项
- 设置程序后台启动,不显示应用图标,参考上述参考链接