3

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
James Marino
  • 668
  • 1
  • 9
  • 25
  • 1
    I highly doubt there is a public API or supported way to do this. So just keep that in mind if you are planning to submit to the Mac App Store or anything like that. – Charlie Fish May 15 '17 at 09:00

1 Answers1

2

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

VenoMKO
  • 3,294
  • 32
  • 38
James Marino
  • 668
  • 1
  • 9
  • 25