我在互联网上广泛搜索了如何以编程方式关闭 Touch Bar,但到目前为止还没有找到解决方案。
我知道这是可能的,因为 Apple 的“QuickTime”应用程序会在播放视频时在屏幕上的控件消失后关闭 Touch Bar。
是否有官方方式来执行此操作,甚至是“hacky”方式?任何帮助将不胜感激。
最佳答案
我找到了一种使用以下脚本关闭触摸栏的方法:
#!/bin/bash
function enableTouchBar() {
local presentationModeProperties="<dict><key>app</key><string>fullControlStrip</string><key>appWithControlStrip</key><string>fullControlStrip</string><key>fullControlStrip</key><string>app</string></dict>"
defaults delete com.apple.touchbar.agent PresentationModeGlobal
defaults write com.apple.touchbar.agent PresentationModeFnModes $presentationModeProperties
launchctl load /System/Library/LaunchAgents/com.apple.controlstrip.plist
launchctl load /System/Library/LaunchAgents/com.apple.touchbar.agent.plist
launchctl load /System/Library/LaunchDaemons/com.apple.touchbar.user-device.plist
pkill "ControlStrip"
pkill "Touch Bar agent"
pkill Dock
}
function disableTouchBar() {
defaults write com.apple.touchbar.agent PresentationModeGlobal -string fullControlStrip
launchctl unload /System/Library/LaunchAgents/com.apple.controlstrip.plist
launchctl unload /System/Library/LaunchAgents/com.apple.touchbar.agent.plist
launchctl unload /System/Library/LaunchDaemons/com.apple.touchbar.user-device.plist
pkill "ControlStrip"
pkill "Touch Bar agent"
pkill Dock
}
{
if [ "$1" == "enable" ]; then
enableTouchBar
elif [ "$1" == "disable" ]; then
disableTouchBar
else
printf "\\nUsage:\\n\\tTouchBar enable\\n\\tTouchBar disable\\n\\n"
fi
}
请注意,在恢复模式下必须禁用系统完整性保护$ csrutil disable
引用资料:
https://github.com/HiKay/TouchBarDisabler https://gist.github.com/JamesMarino/1c628e9ad57e21684cd5e8ec139b7e98
关于objective-c - 关闭/隐藏 Touch Bar - MacBook Pro 2016,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43920720/