Compare commits

..
9 Commits
Author SHA1 Message Date
toxblh 59a8bb6430 patch. work on macos version >=10.12.2 2018-04-09 11:35:39 +01:00
toxblh 2dc1148a2a fix readme 2018-04-09 08:52:07 +01:00
toxblh d12bdd2bd4 added new screenshot 2018-04-09 08:46:09 +01:00
toxblh 92b6e5ef33 full media keys 2018-04-09 08:40:38 +01:00
Anton Palgunov d97d8efdd4 Merge pull request #2 from Toxblh/add-license-1
Create LICENSE
2018-04-09 08:33:20 +01:00
Anton Palgunov 9f6f7d9404 Create LICENSE 2018-04-09 08:33:02 +01:00
Anton Palgunov 528506f276 Merge pull request #1 from ReDetection/master
TouchBar without the cross and stripe menu
2018-04-09 08:31:34 +01:00
Serg ce7c3c5883 display custom touchbar without control strip and builtin close button 2018-04-09 13:16:14 +07:00
Serg 3d3ad0f076 add readme into project (no target) for convenience 2018-04-09 13:15:52 +07:00
8 changed files with 73 additions and 38 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Anton Palgunov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+4 -2
View File
@@ -40,6 +40,7 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
36C2ECD2207B3B1D003CDA33 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
B059D621205E03F5006E6B86 /* TouchBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarController.swift; sourceTree = "<group>"; }; B059D621205E03F5006E6B86 /* TouchBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarController.swift; sourceTree = "<group>"; };
B059D623205E04F3006E6B86 /* TouchBarItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarItems.swift; sourceTree = "<group>"; }; B059D623205E04F3006E6B86 /* TouchBarItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarItems.swift; sourceTree = "<group>"; };
B059D629205E13E5006E6B86 /* TouchBarPrivateApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarPrivateApi.h; sourceTree = "<group>"; }; B059D629205E13E5006E6B86 /* TouchBarPrivateApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarPrivateApi.h; sourceTree = "<group>"; };
@@ -102,6 +103,7 @@
B082B246205C7D8000BC04DC = { B082B246205C7D8000BC04DC = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
36C2ECD2207B3B1D003CDA33 /* README.md */,
B082B251205C7D8000BC04DC /* MTMR */, B082B251205C7D8000BC04DC /* MTMR */,
B082B264205C7D8000BC04DC /* MTMRTests */, B082B264205C7D8000BC04DC /* MTMRTests */,
B082B26F205C7D8000BC04DC /* MTMRUITests */, B082B26F205C7D8000BC04DC /* MTMRUITests */,
@@ -402,7 +404,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13; MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx; SDKROOT = macosx;
@@ -455,7 +457,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13; MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+5 -1
View File
@@ -14,7 +14,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) { func applicationDidFinishLaunching(_ aNotification: Notification) {
TouchBarController.shared.setupControlStripPresence() if #available(OSX 10.12.2, *) {
TouchBarController.shared.setupControlStripPresence()
} else {
// Fallback on earlier versions
}
// Insert code here to initialize your application // Insert code here to initialize your application
} }
+39 -33
View File
@@ -8,31 +8,33 @@
import Cocoa import Cocoa
@available(OSX 10.12.2, *)
class TouchBarController: NSObject, NSTouchBarDelegate { class TouchBarController: NSObject, NSTouchBarDelegate {
static let shared = TouchBarController() static let shared = TouchBarController()
let touchBar = NSTouchBar() let touchBar = NSTouchBar()
var timer = Timer() var timer = Timer()
var timeButton: NSButton = NSButton() var timeButton: NSButton = NSButton()
private override init() { private override init() {
super.init() super.init()
touchBar.delegate = self touchBar.delegate = self
touchBar.defaultItemIdentifiers = [ touchBar.defaultItemIdentifiers = [
.escButton, .escButton,
.dismissButton,
.brightDown, .brightDown,
.brightUp, .brightUp,
.prev, .prev,
.play, .play,
.next, .next,
.sleep, .sleep,
.weather, .weather,
.volumeDown, .volumeDown,
.volumeUp, .volumeUp,
.battery, .battery,
@@ -49,26 +51,30 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, true) DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, true)
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateTime), userInfo: nil, repeats: true) timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateTime), userInfo: nil, repeats: true)
} }
func updateControlStripPresence() { func updateControlStripPresence() {
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, true) DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, true)
} }
@objc private func presentTouchBar() { @objc private func presentTouchBar() {
NSTouchBar.presentSystemModalFunctionBar(touchBar, systemTrayItemIdentifier: .controlStripItem) NSTouchBar.presentSystemModalFunctionBar(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
} }
private func dismissTouchBar() { @objc private func dismissTouchBar() {
NSTouchBar.minimizeSystemModalFunctionBar(touchBar) NSTouchBar.minimizeSystemModalFunctionBar(touchBar)
} }
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? { func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
switch identifier { switch identifier {
case .escButton: case .escButton:
let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
item.view = NSButton(title: "esc", target: self, action: #selector(handleEsc)) item.view = NSButton(title: "esc", target: self, action: #selector(handleEsc))
return item return item
case .dismissButton:
let item = NSCustomTouchBarItem(identifier: identifier)
item.view = NSButton(title: "exit", target: self, action: #selector(dismissTouchBar))
return item
case .brightUp: case .brightUp:
let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
item.view = NSButton(title: "🔆", target: self, action: #selector(handleBrightUp)) item.view = NSButton(title: "🔆", target: self, action: #selector(handleBrightUp))
@@ -86,11 +92,11 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
item.view = NSButton(title: "🔊", target: self, action: #selector(handleVolumeUp)) item.view = NSButton(title: "🔊", target: self, action: #selector(handleVolumeUp))
return item return item
// case .prev: case .prev:
// let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
// item.view = NSButton(title: "⏪", target: self, action: #selector(handlePrev)) item.view = NSButton(title: "⏪", target: self, action: #selector(handlePrev))
// return item return item
case .play: case .play:
let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
item.view = NSButton(title: "⏯", target: self, action: #selector(handlePlay)) item.view = NSButton(title: "⏯", target: self, action: #selector(handlePlay))
@@ -99,18 +105,18 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
item.view = NSButton(title: "⏩", target: self, action: #selector(handleNext)) item.view = NSButton(title: "⏩", target: self, action: #selector(handleNext))
return item return item
case .time: case .time:
let item = NSCustomTouchBarItem(identifier: identifier) let item = NSCustomTouchBarItem(identifier: identifier)
timeButton = NSButton(title: self.getCurrentTime(), target: self, action: nil) timeButton = NSButton(title: self.getCurrentTime(), target: self, action: nil)
item.view = timeButton item.view = timeButton
return item return item
default: default:
return nil return nil
} }
} }
func getCurrentTime() -> String { func getCurrentTime() -> String {
let date = Date() let date = Date()
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
@@ -118,50 +124,50 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let timestamp = dateFormatter.string(from: date) let timestamp = dateFormatter.string(from: date)
return timestamp return timestamp
} }
@objc func updateTime() { @objc func updateTime() {
timeButton.title = getCurrentTime() timeButton.title = getCurrentTime()
} }
@objc func handleEsc() { @objc func handleEsc() {
let sender = ESCKeyPress() let sender = ESCKeyPress()
sender.send() sender.send()
} }
@objc func handleVolumeUp() { @objc func handleVolumeUp() {
HIDPostAuxKey(Int(NX_KEYTYPE_SOUND_UP)) HIDPostAuxKey(Int(NX_KEYTYPE_SOUND_UP))
} }
@objc func handleVolumeDown() { @objc func handleVolumeDown() {
HIDPostAuxKey(Int(NX_KEYTYPE_SOUND_DOWN)) HIDPostAuxKey(Int(NX_KEYTYPE_SOUND_DOWN))
} }
@objc func handleBrightDown() { @objc func handleBrightDown() {
// HIDPostAuxKey(Int(NX_KEYTYPE_BRIGHTNESS_DOWN)) // HIDPostAuxKey(Int(NX_KEYTYPE_BRIGHTNESS_DOWN))
let sender = BrightnessUpPress() let sender = BrightnessUpPress()
sender.send() sender.send()
} }
@objc func handleBrightUp() { @objc func handleBrightUp() {
// HIDPostAuxKey(Int(NX_KEYTYPE_BRIGHTNESS_UP)) // HIDPostAuxKey(Int(NX_KEYTYPE_BRIGHTNESS_UP))
let sender = BrightnessDownPress() let sender = BrightnessDownPress()
sender.send() sender.send()
} }
@objc func handlePrev() { @objc func handlePrev() {
HIDPostAuxKey(Int(NX_KEYTYPE_PREVIOUS)) HIDPostAuxKey(Int(NX_KEYTYPE_PREVIOUS))
} }
@objc func handlePlay() { @objc func handlePlay() {
HIDPostAuxKey(Int(NX_KEYTYPE_PLAY)) HIDPostAuxKey(Int(NX_KEYTYPE_PLAY))
} }
@objc func handleNext() { @objc func handleNext() {
HIDPostAuxKey(Int(NX_KEYTYPE_NEXT)) HIDPostAuxKey(Int(NX_KEYTYPE_NEXT))
} }
// func getBattery() { // func getBattery() {
// var error: NSDictionary? // var error: NSDictionary?
// if let scriptObject = NSAppleScript(source: <#T##String#>) { // if let scriptObject = NSAppleScript(source: <#T##String#>) {
+2
View File
@@ -8,8 +8,10 @@
import Cocoa import Cocoa
@available(OSX 10.12.2, *)
extension NSTouchBarItem.Identifier { extension NSTouchBarItem.Identifier {
static let escButton = NSTouchBarItem.Identifier("com.toxblh.mtmr.escButton") static let escButton = NSTouchBarItem.Identifier("com.toxblh.mtmr.escButton")
static let dismissButton = NSTouchBarItem.Identifier("com.toxblh.mtmr.dismissButton")
// Volume // Volume
static let volumeUp = NSTouchBarItem.Identifier("com.toxblh.mtmr.volumeUp") static let volumeUp = NSTouchBarItem.Identifier("com.toxblh.mtmr.volumeUp")
+2 -2
View File
@@ -5,7 +5,7 @@
# My TouchBar. My rules # My TouchBar. My rules
<p align="center"> <p align="center">
<img src="Resources/TouchBarV0.1.png"> <img src="Resources/TouchBar-v0.2.png">
</p> </p>
My the idea is to create the program like a platform for plugins for customization TouchBar. I very like BTT and a full custom TouchBar. And I want to create it. And it's my the first Swift project for MacOS :) My the idea is to create the program like a platform for plugins for customization TouchBar. I very like BTT and a full custom TouchBar. And I want to create it. And it's my the first Swift project for MacOS :)
@@ -17,6 +17,6 @@ My the idea is to create the program like a platform for plugins for customizati
- [x] Time in touchbar! - [x] Time in touchbar!
- [ ] First the weather plugin - [ ] First the weather plugin
- [ ] Create the same panel like in my [BTT preset](https://github.com/Toxblh/btt-touchbar-preset) - [ ] Create the same panel like in my [BTT preset](https://github.com/Toxblh/btt-touchbar-preset)
- [ ] Find how to open full-screen TouchBar without the cross and stripe menu - [x] Find how to open full-screen TouchBar without the cross and stripe menu
- [ ] Find how to add haptic feedback - [ ] Find how to add haptic feedback
- [ ] Refactoring the application on packages (AppleScript, JavaScript? and Swift?) - [ ] Refactoring the application on packages (AppleScript, JavaScript? and Swift?)

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB