objective-cmacosmacbookpro-touch-bar

Turning off / Hiding the Touch Bar - MacBook Pro 2016


I have extensively searched internet for how to programatically turn off the Touch Bar, but have had no luck so far in finding a solution.

I know this is possible due to Apple's "QuickTime" app turning off the Touch Bar when a video is playing after the on screen controls fade away.

Would there be an official way to do this, or even a "hacky" way? Any help would be much appreciated.


Solution

  • I have found a way to turn off the touch bar using the script below:

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

    Please note, System Integrity Protection must be disabled $ csrutil disable in recovery mode

    References:

    https://github.com/HiKay/TouchBarDisabler https://gist.github.com/JamesMarino/1c628e9ad57e21684cd5e8ec139b7e98