3

我在互联网上广泛搜索了如何以编程方式关闭 Touch Bar,但到目前为止还没有找到解决方案。

我知道这是可能的,因为在屏幕控件消失后播放视频时,Apple 的“QuickTime”应用程序会关闭 Touch Bar。

会有官方的方式来做到这一点,甚至是“hacky”方式吗?任何帮助将非常感激。

4

1 回答 1

2

我找到了一种使用以下脚本关闭触摸栏的方法:

#!/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

于 2017-05-15T01:58:35.827 回答