Skip to content

Instantly share code, notes, and snippets.

@JamesMarino
Created May 15, 2017 01:53
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save JamesMarino/1c628e9ad57e21684cd5e8ec139b7e98 to your computer and use it in GitHub Desktop.
Save JamesMarino/1c628e9ad57e21684cd5e8ec139b7e98 to your computer and use it in GitHub Desktop.
Disable the TouchBar
#!/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
}
@JamesMarino
Copy link
Author

Note, System Integrity Protection must be disabled

@YixuanCao
Copy link

Hi, recently I have to disable my touchbar as it flash all the time.
As I tried your gist, there are something wrong:

% ./disable_touchbar.sh disable                                                                                                                                                                                                                                                                                                                                     !6154
/System/Library/LaunchAgents/com.apple.controlstrip.plist: Operation now in progress
/System/Library/LaunchAgents/com.apple.touchbar.agent.plist: No such file or directory
/System/Library/LaunchDaemons/com.apple.touchbar.user-device.plist: No such file or directory

I am on macOS Catalina 10.15,
And the only thing I found related to touchbar in /System/Library/LaunchAgents/com.* is
/System/Library/LaunchAgents/com.apple.SpacesTouchBarAgent.plist.

Can you update your gist for this system version?
Thank you!

@alexandermckay
Copy link

Absolute life saver

@pwdonald
Copy link

Hi, recently I have to disable my touchbar as it flash all the time.
As I tried your gist, there are something wrong:

% ./disable_touchbar.sh disable                                                                                                                                                                                                                                                                                                                                     !6154
/System/Library/LaunchAgents/com.apple.controlstrip.plist: Operation now in progress
/System/Library/LaunchAgents/com.apple.touchbar.agent.plist: No such file or directory
/System/Library/LaunchDaemons/com.apple.touchbar.user-device.plist: No such file or directory

I am on macOS Catalina 10.15,
And the only thing I found related to touchbar in /System/Library/LaunchAgents/com.* is
/System/Library/LaunchAgents/com.apple.SpacesTouchBarAgent.plist.

Can you update your gist for this system version?
Thank you!

Same problem here... Anyone have any suggestions?

@blackvvine
Copy link

Those paths do not exist in Big Sur. However, the following seems to kill the Touch Bar server:

defaults write com.apple.touchbar.agent PresentationModeGlobal -string fullControlStrip

launchctl unload /System/Library/LaunchDaemons/com.apple.touchbarserver.plist
launchctl unload /System/Library/LaunchAgents/com.apple.controlstrip.plist

pkill "ControlStrip"
pkill "Touch Bar 
pkill Dock

I don't know how to make the TocuhBar blank, however for me the point was killing the touch response, so this is good enough.

@chuanqizhang
Copy link

Those paths do not exist in Big Sur. However, the following seems to kill the Touch Bar server:

defaults write com.apple.touchbar.agent PresentationModeGlobal -string fullControlStrip

launchctl unload /System/Library/LaunchDaemons/com.apple.touchbarserver.plist
launchctl unload /System/Library/LaunchAgents/com.apple.controlstrip.plist

pkill "ControlStrip"
pkill "Touch Bar 
pkill Dock

I don't know how to make the TocuhBar blank, however for me the point was killing the touch response, so this is good enough.

This also did work for me, under System Integrity Protection being disabled. However, if I restarted my machine to enable SIP, then it would not work anymore. So it seems I have to disable SIP all the time. Does anyone have a solution to this?

@chuanqizhang
Copy link

Those paths do not exist in Big Sur. However, the following seems to kill the Touch Bar server:

defaults write com.apple.touchbar.agent PresentationModeGlobal -string fullControlStrip

launchctl unload /System/Library/LaunchDaemons/com.apple.touchbarserver.plist
launchctl unload /System/Library/LaunchAgents/com.apple.controlstrip.plist

pkill "ControlStrip"
pkill "Touch Bar 
pkill Dock

I don't know how to make the TocuhBar blank, however for me the point was killing the touch response, so this is good enough.

By the way, after a few trials, I found running launchctl remove com.apple.controlstrip before launchctl unload... could realize the effect to make TocuhBar blank.

@eisukeesaki
Copy link

eisukeesaki commented Feb 2, 2023

works as expected but I get the following error messages.

OS: macOS 12.6.2 (21G320)
HW: MacBook Pro 2018 - Intel 8950HK

$>./TouchBar disable
Unload failed: 5: Input/output error
Try running `launchctl bootout` as root for richer errors.
Warning: Expecting a LaunchAgents path since the command was ran as user. Got LaunchDaemons instead.
`launchctl bootout` is a recommended alternative.
Unload failed: 5: Input/output error
Try running `launchctl bootout` as root for richer errors.
$>./TouchBar enable
Load failed: 5: Input/output error
Try running `launchctl bootstrap` as root for richer errors.
Warning: Expecting a LaunchAgents path since the command was ran as user. Got LaunchDaemons instead.
`launchctl bootstrap` is a recommended alternative.
Load failed: 5: Input/output error
Try running `launchctl bootstrap` as root for richer errors.

@eisukeesaki
Copy link

eisukeesaki commented Feb 2, 2023

I'm having an issue where my Touch Bar flashes when certain conditions are met. I had expected that running disableTouchBar() would prevent that from happening, but interestingly the flashing issue still persists, despite running the script.

update: restarting touchbar related processes has solved the touchbar flashing issue. sudo pkill TouchBarServer, killall ControlStrip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment