Display anything you want on Touch Bar right side of brightness button
This is a Swift version of touch-baer
This uses a private API to display what you want on Touch Bar as a button, it is totally safe!
-
Download or git clone my repo
-
Copy the
TouchBar.h
file to your projectIf you are on Swift, you should also create a bridging file
-
Embed
DFRFoundation.framework
to your target in the Xcode.DFRFoundation.framework
can be found in/System/Library/PrivateFrameworks/DFRFoundation.framework
of your Mac
var touchBarButton: NSButton?
DFRSystemModalShowsCloseBoxWhenFrontMost(true)
let touchBarIdentifier = NSTouchBarItem.Identifier(rawValue: "TouchBar")
let touchBarItem = NSCustomTouchBarItem.init(identifier: touchBarIdentifier)
touchBarButton = NSButton(title: "Hello World!", target: nil, action: nil)
touchBarItem.view = touchBarButton!
NSTouchBarItem.addSystemTrayItem(touchBarItem)
DFRElementSetControlStripPresenceForIdentifier(touchBarIdentifier, true)
-
Show close button or not
DFRSystemModalShowsCloseBoxWhenFrontMost(true)
A close button can be like this:
-
ClockBar - Clock, right on the Touch Bar
-
DarkLight - Switch between Dark and Light mode with an ease
Big thanks to Alexsander Akers and his project touch-baer