关闭/隐藏 Touch Bar - MacBook Pro 2016

Turning off / Hiding the Touch Bar - MacBook Pro 2016

我在互联网上广泛搜索了如何以编程方式关闭 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 [ "" == "enable" ]; then
        enableTouchBar
    elif [ "" == "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