mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-10-31 02:18:35 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5504e5d640 | ||
|
|
8a73fe01e4 | ||
|
|
5fbb2bafc6 | ||
|
|
5b6b6dfa56 | ||
|
|
7c9dd26eb0 | ||
|
|
40fa61fcb5 | ||
|
|
5a8117ac7f | ||
|
|
a606767ddc | ||
|
|
6badc37dc3 | ||
|
|
4497c7102c | ||
|
|
b6c6bb945b | ||
|
|
3e399d14c2 | ||
|
|
624c8ac6d8 | ||
|
|
ea68ce33c1 | ||
|
|
744ea067db | ||
|
|
8064ab759c | ||
|
|
556c28df85 | ||
|
|
e68f930efa | ||
|
|
647ac0ba20 | ||
|
|
780a8ba81e | ||
|
|
71f5030fa6 | ||
|
|
f435c0b530 | ||
|
|
e278482807 | ||
|
|
51d246bf7f | ||
|
|
c1cd402241 | ||
|
|
c496156cf2 | ||
|
|
154ea09e98 | ||
|
|
3b493fd5be |
@@ -46,6 +46,7 @@
|
||||
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B082B252205C7D8000BC04DC /* AppDelegate.swift */; };
|
||||
B082B257205C7D8000BC04DC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B082B256205C7D8000BC04DC /* Assets.xcassets */; };
|
||||
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B082B258205C7D8000BC04DC /* Main.storyboard */; };
|
||||
B0846A752220C968000288A7 /* NetworkBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0846A742220C968000288A7 /* NetworkBarItem.swift */; };
|
||||
B09EB1E4207C082000D5C1E0 /* HapticFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */; };
|
||||
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */; };
|
||||
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */; };
|
||||
@@ -60,6 +61,7 @@
|
||||
B0B17439207D6B590004B740 /* Vox.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B1742F207D6B590004B740 /* Vox.nowPlaying.scpt */; };
|
||||
B0B1743A207D6B590004B740 /* iTunes.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B17430207D6B590004B740 /* iTunes.nowPlaying.scpt */; };
|
||||
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */; };
|
||||
B0F54A7A2295AC7D00B4C509 /* DarkModeBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */; };
|
||||
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@@ -126,6 +128,7 @@
|
||||
B082B25C205C7D8000BC04DC /* MTMR.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MTMR.entitlements; sourceTree = "<group>"; };
|
||||
B082B261205C7D8000BC04DC /* MTMRTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MTMRTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B082B267205C7D8000BC04DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
B0846A742220C968000288A7 /* NetworkBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkBarItem.swift; sourceTree = "<group>"; };
|
||||
B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticFeedback.swift; sourceTree = "<group>"; };
|
||||
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MultitouchSupport.framework; path = ../../../../../System/Library/PrivateFrameworks/MultitouchSupport.framework; sourceTree = "<group>"; };
|
||||
B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPress.swift; sourceTree = "<group>"; };
|
||||
@@ -140,6 +143,7 @@
|
||||
B0B1742F207D6B590004B740 /* Vox.nowPlaying.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Vox.nowPlaying.scpt; sourceTree = "<group>"; };
|
||||
B0B17430207D6B590004B740 /* iTunes.nowPlaying.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = iTunes.nowPlaying.scpt; sourceTree = "<group>"; };
|
||||
B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportNSTouchBar.swift; sourceTree = "<group>"; };
|
||||
B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkModeBarItem.swift; sourceTree = "<group>"; };
|
||||
B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TouchBarSupport.m; sourceTree = "<group>"; };
|
||||
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarSupport.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -276,20 +280,22 @@
|
||||
B0B88A07208CD12000A2C160 /* Widgets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
36C2ECD6207B6DAE003CDA33 /* TimeTouchBarItem.swift */,
|
||||
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */,
|
||||
6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */,
|
||||
B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */,
|
||||
607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */,
|
||||
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */,
|
||||
6042B6A62083E03A00C525C8 /* AppScrubberTouchBarItem.swift */,
|
||||
B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */,
|
||||
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */,
|
||||
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */,
|
||||
B081732B213739FE005D4908 /* DnDBarItem.swift */,
|
||||
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
|
||||
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */,
|
||||
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */,
|
||||
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
|
||||
B0846A742220C968000288A7 /* NetworkBarItem.swift */,
|
||||
B08173262135F02B005D4908 /* NightShiftBarItem.swift */,
|
||||
B081732B213739FE005D4908 /* DnDBarItem.swift */,
|
||||
B08126EE217BD0B900A98970 /* PomodoroBarItem.swift */,
|
||||
36C2ECD6207B6DAE003CDA33 /* TimeTouchBarItem.swift */,
|
||||
6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */,
|
||||
607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */,
|
||||
B08126F0217BE19000A98970 /* WidgetProtocol.swift */,
|
||||
B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */,
|
||||
);
|
||||
path = Widgets;
|
||||
sourceTree = "<group>";
|
||||
@@ -437,11 +443,13 @@
|
||||
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */,
|
||||
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */,
|
||||
36C2ECD9207B74B4003CDA33 /* AppleScriptTouchBarItem.swift in Sources */,
|
||||
B0846A752220C968000288A7 /* NetworkBarItem.swift in Sources */,
|
||||
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */,
|
||||
B08126F1217BE19000A98970 /* WidgetProtocol.swift in Sources */,
|
||||
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */,
|
||||
6042B6A72083E03A00C525C8 /* AppScrubberTouchBarItem.swift in Sources */,
|
||||
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */,
|
||||
B0F54A7A2295AC7D00B4C509 /* DarkModeBarItem.swift in Sources */,
|
||||
B08126EF217BD0B900A98970 /* PomodoroBarItem.swift in Sources */,
|
||||
B081732C213739FE005D4908 /* DnDBarItem.swift in Sources */,
|
||||
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */,
|
||||
@@ -626,7 +634,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = D6D8BR2QNB;
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildSystemType</key>
|
||||
<string>Latest</string>
|
||||
<string>Original</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -9,13 +9,19 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
||||
self.interval = interval
|
||||
super.init(identifier: identifier, title: "⏳")
|
||||
forceHideConstraint = view.widthAnchor.constraint(equalToConstant: 0)
|
||||
guard let script = source.appleScript else {
|
||||
title = "no script"
|
||||
return
|
||||
}
|
||||
self.script = script
|
||||
isBordered = false
|
||||
title = "scheduled"
|
||||
DispatchQueue.appleScriptQueue.async {
|
||||
guard let script = source.appleScript else {
|
||||
DispatchQueue.main.async {
|
||||
self.title = "no script"
|
||||
}
|
||||
return
|
||||
}
|
||||
self.script = script
|
||||
DispatchQueue.main.async {
|
||||
self.isBordered = false
|
||||
}
|
||||
|
||||
var error: NSDictionary?
|
||||
guard script.compileAndReturnError(&error) else {
|
||||
#if DEBUG
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "sun-icon-256.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "39857.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.19.4</string>
|
||||
<string>0.21</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>140</string>
|
||||
<string>207</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -338,6 +338,8 @@ enum ItemType: Decodable {
|
||||
case nightShift()
|
||||
case dnd()
|
||||
case pomodoro(workTime: Double, restTime: Double)
|
||||
case network(flip: Bool)
|
||||
case darkMode()
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
@@ -358,6 +360,7 @@ enum ItemType: Decodable {
|
||||
case items
|
||||
case workTime
|
||||
case restTime
|
||||
case flip
|
||||
}
|
||||
|
||||
enum ItemTypeRaw: String, Decodable {
|
||||
@@ -376,6 +379,8 @@ enum ItemType: Decodable {
|
||||
case nightShift
|
||||
case dnd
|
||||
case pomodoro
|
||||
case network
|
||||
case darkMode
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
@@ -444,6 +449,13 @@ enum ItemType: Decodable {
|
||||
let workTime = try container.decodeIfPresent(Double.self, forKey: .workTime) ?? 1500.0
|
||||
let restTime = try container.decodeIfPresent(Double.self, forKey: .restTime) ?? 600.0
|
||||
self = .pomodoro(workTime: workTime, restTime: restTime)
|
||||
|
||||
case .network:
|
||||
let flip = try container.decodeIfPresent(Bool.self, forKey: .flip) ?? false
|
||||
self = .network(flip: flip)
|
||||
|
||||
case .darkMode:
|
||||
self = .darkMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ extension ItemType {
|
||||
return "com.toxblh.mtmr.dnd."
|
||||
case .pomodoro(interval: _):
|
||||
return PomodoroBarItem.identifier
|
||||
case .network(flip: _):
|
||||
return NetworkBarItem.identifier
|
||||
case .darkMode(items: _):
|
||||
return DarkModeBarItem.identifier
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,6 +283,10 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = DnDBarItem(identifier: identifier)
|
||||
case let .pomodoro(workTime: workTime, restTime: restTime):
|
||||
barItem = PomodoroBarItem(identifier: identifier, workTime: workTime, restTime: restTime)
|
||||
case let .network(flip: flip):
|
||||
barItem = NetworkBarItem(identifier: identifier, flip: flip)
|
||||
case .darkMode():
|
||||
barItem = DarkModeBarItem(identifier: identifier)
|
||||
}
|
||||
|
||||
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import Foundation
|
||||
|
||||
class DarkModeBarItem: CustomButtonTouchBarItem, Widget {
|
||||
static var name: String = "darkmode"
|
||||
static var identifier: String = "com.toxblh.mtmr.darkmode"
|
||||
|
||||
private var timer: Timer!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier) {
|
||||
super.init(identifier: identifier, title: "")
|
||||
isBordered = false
|
||||
setWidth(value: 24)
|
||||
|
||||
tapClosure = { [weak self] in self?.DarkModeToggle() }
|
||||
|
||||
timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func DarkModeToggle() {
|
||||
DarkMode.isEnabled = !DarkMode.isEnabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
@objc func refresh() {
|
||||
image = DarkMode.isEnabled ? #imageLiteral(resourceName: "dark-mode-on") : #imageLiteral(resourceName: "dark-mode-off")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct DarkMode {
|
||||
private static let prefix = "tell application \"System Events\" to tell appearance preferences to"
|
||||
|
||||
static var isEnabled: Bool {
|
||||
get {
|
||||
return UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark"
|
||||
}
|
||||
set {
|
||||
toggle(force: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static func toggle(force: Bool? = nil) {
|
||||
let value = force.map(String.init) ?? "not dark mode"
|
||||
runAppleScript("\(prefix) set dark mode to \(value)")
|
||||
}
|
||||
}
|
||||
|
||||
func runAppleScript(_ source: String) -> String? {
|
||||
return NSAppleScript(source: source)?.executeAndReturnError(nil).stringValue
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// NetworkBarItem.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Anton Palgunov on 23/02/2019.
|
||||
// Copyright © 2019 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class NetworkBarItem: CustomButtonTouchBarItem, Widget {
|
||||
static var name: String = "network"
|
||||
static var identifier: String = "com.toxblh.mtmr.network"
|
||||
|
||||
private let flip: Bool
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, flip: Bool = false) {
|
||||
self.flip = flip
|
||||
super.init(identifier: identifier, title: " ")
|
||||
startMonitoringProcess()
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func startMonitoringProcess() {
|
||||
var pipe: Pipe
|
||||
var outputHandle: FileHandle
|
||||
var bandwidthProcess: Process?
|
||||
var dSpeed: UInt64?
|
||||
var uSpeed: UInt64?
|
||||
var curr: Array<Substring>?
|
||||
var dataAvailable: NSObjectProtocol!
|
||||
|
||||
pipe = Pipe()
|
||||
bandwidthProcess = Process()
|
||||
bandwidthProcess?.launchPath = "/usr/bin/env"
|
||||
bandwidthProcess?.arguments = ["netstat", "-w1", "-l", "en0"]
|
||||
bandwidthProcess?.standardOutput = pipe
|
||||
|
||||
outputHandle = pipe.fileHandleForReading
|
||||
outputHandle.waitForDataInBackgroundAndNotify(forModes: [RunLoop.Mode.common])
|
||||
|
||||
dataAvailable = NotificationCenter.default.addObserver(
|
||||
forName: NSNotification.Name.NSFileHandleDataAvailable,
|
||||
object: outputHandle,
|
||||
queue: nil
|
||||
) { _ -> Void in
|
||||
let data = pipe.fileHandleForReading.availableData
|
||||
if data.count > 0 {
|
||||
if let str = NSString(data: data, encoding: String.Encoding.utf8.rawValue) {
|
||||
curr = [""]
|
||||
curr = str
|
||||
.replacingOccurrences(of: " ", with: " ")
|
||||
.split(separator: " ")
|
||||
if curr == nil || (curr?.count)! < 6 {} else {
|
||||
if Int64(curr![2]) == nil {} else {
|
||||
dSpeed = UInt64(curr![2])
|
||||
uSpeed = UInt64(curr![5])
|
||||
|
||||
self.setTitle(up: self.getHumanizeSize(speed: uSpeed!), down: self.getHumanizeSize(speed: dSpeed!))
|
||||
}
|
||||
}
|
||||
}
|
||||
outputHandle.waitForDataInBackgroundAndNotify()
|
||||
} else {
|
||||
NotificationCenter.default.removeObserver(dataAvailable)
|
||||
}
|
||||
}
|
||||
|
||||
var dataReady: NSObjectProtocol!
|
||||
dataReady = NotificationCenter.default.addObserver(
|
||||
forName: Process.didTerminateNotification,
|
||||
object: outputHandle,
|
||||
queue: nil
|
||||
) { _ -> Void in
|
||||
print("Task terminated!")
|
||||
NotificationCenter.default.removeObserver(dataReady)
|
||||
}
|
||||
|
||||
bandwidthProcess?.launch()
|
||||
}
|
||||
|
||||
func getHumanizeSize(speed: UInt64) -> String {
|
||||
let humanText: String
|
||||
|
||||
if speed < 1024 {
|
||||
humanText = String(format: "%.0f", Double(speed)) + " B/s"
|
||||
} else if speed < (1024 * 1024) {
|
||||
humanText = String(format: "%.1f", Double(speed) / 1024) + " KB/s"
|
||||
} else if speed < (1024 * 1024 * 1024) {
|
||||
humanText = String(format: "%.1f", Double(speed) / (1024 * 1024)) + " MB/s"
|
||||
} else {
|
||||
humanText = String(format: "%.2f", Double(speed) / (1024 * 1024 * 1024)) + " GB/s"
|
||||
}
|
||||
|
||||
return humanText
|
||||
}
|
||||
|
||||
func appendUpSpeed(appendString: NSMutableAttributedString, up: String, titleFont: NSFont, newStr: Bool = false) {
|
||||
appendString.append(NSMutableAttributedString(
|
||||
string: newStr ? "\n↑" : "↑",
|
||||
attributes: [
|
||||
NSAttributedString.Key.foregroundColor: NSColor.blue,
|
||||
NSAttributedString.Key.font: titleFont,
|
||||
]))
|
||||
|
||||
appendString.append(NSMutableAttributedString(
|
||||
string: up,
|
||||
attributes: [
|
||||
NSAttributedString.Key.font: titleFont,
|
||||
]))
|
||||
}
|
||||
|
||||
func appendDownSpeed(appendString: NSMutableAttributedString, down: String, titleFont: NSFont, newStr: Bool = false) {
|
||||
appendString.append(NSMutableAttributedString(
|
||||
string: newStr ? "\n↓" : "↓",
|
||||
attributes: [
|
||||
NSAttributedString.Key.foregroundColor: NSColor.red,
|
||||
NSAttributedString.Key.font: titleFont,
|
||||
]))
|
||||
|
||||
appendString.append(NSMutableAttributedString(
|
||||
string: down,
|
||||
attributes: [
|
||||
NSAttributedString.Key.font: titleFont
|
||||
]))
|
||||
}
|
||||
|
||||
func setTitle(up: String, down: String) {
|
||||
let titleFont = NSFont.monospacedDigitSystemFont(ofSize: 12, weight: NSFont.Weight.light)
|
||||
|
||||
let newTitle: NSMutableAttributedString = NSMutableAttributedString(string: "")
|
||||
|
||||
if (self.flip) {
|
||||
appendUpSpeed(appendString: newTitle, up: up, titleFont: titleFont)
|
||||
appendDownSpeed(appendString: newTitle, down: down, titleFont: titleFont, newStr: true)
|
||||
} else {
|
||||
appendDownSpeed(appendString: newTitle, down: down, titleFont: titleFont)
|
||||
appendUpSpeed(appendString: newTitle, up: up, titleFont: titleFont, newStr: true)
|
||||
}
|
||||
|
||||
|
||||
self.attributedTitle = newTitle
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,4 @@
|
||||
protocol Widget {
|
||||
static var name: String { get }
|
||||
static var identifier: String { get }
|
||||
static var decoder: ParametersDecoder { get }
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
</p>
|
||||
|
||||
**MTMR** Community:
|
||||
[<img height="24px" src="https://github.com/discourse/DiscourseMobile/raw/master/icon.png" /> Discourse](https://forum.mtmr.app)
|
||||
[<img height="24px" src="https://camo.githubusercontent.com/88f53948f291c54736bf08f5fd7b037a848dfc62/68747470733a2f2f646973636f72646170702e636f6d2f6173736574732f30376463613830613130326434313439653937333664346231363263666636662e69636f"> Discord](https://discord.gg/CmNcDuQ)
|
||||
[<img height="24px" src="https://telegram.org/img/t_logo.png" /> Telegram](https://t.me/joinchat/AmVYGg8vW38c13_3MxdE_g)
|
||||
|
||||
<a href="https://www.paypal.me/toxblh/10" title="Donate via Paypal"><img height="32px" src="Resources/support_paypal.svg" alt="PayPal donate button" /></a>
|
||||
<a href="https://www.buymeacoffee.com/toxblh" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" height="32px" ></a>
|
||||
<a href="https://www.patreon.com/bePatron?u=9900748"><img height="32px" src="https://c5.patreon.com/external/logo/become_a_patron_button.png" srcset="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png 2x"></a>
|
||||
[<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/854859-e299e139ab7f79855c0bc589f10b0ec6-medium_jpg.jpg?buster=1453074480" height="32px" /> Become a backer](https://opencollective.com/MTMR#backer)
|
||||
[<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/854859-e299e139ab7f79855c0bc589f10b0ec6-medium_jpg.jpg?buster=1453074480" height="32px" /> Become a sponsor](https://opencollective.com/MTMR#sponsor)
|
||||
<a href="https://www.paypal.me/toxblh/10" title="Donate via Paypal"><img height="36px" src="Resources/support_paypal.svg" alt="PayPal donate button" /></a>
|
||||
<a href="https://www.buymeacoffee.com/toxblh" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" height="36px" ></a>
|
||||
<a href="https://www.patreon.com/bePatron?u=9900748"><img height="36px" src="https://c5.patreon.com/external/logo/become_a_patron_button.png" srcset="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png 2x"></a>
|
||||
<a href="https://www.producthunt.com/posts/my-touchbar-my-rules-mtmr">
|
||||
<img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=my-touchbar-my-rules-mtmr&theme=light" alt="My TouchBar My Rules (MTMR)" height="36px" style="max-width:100%">
|
||||
</a>
|
||||
|
||||
|
||||
My idea is to create a platform for creating plugins to customize the TouchBar. I very much like BTT and having a full custom TouchBar (my [BTT preset](https://github.com/Toxblh/btt-touchbar-preset)), and I wanted to create it. It's my first Swift project for MacOS :)
|
||||
@@ -31,6 +31,24 @@ My idea is to create a platform for creating plugins to customize the TouchBar.
|
||||
- Download lastest [release](https://github.com/Toxblh/MTMR/releases) from github
|
||||
- Or via Homebrew `brew cask install mtmr`
|
||||
|
||||
> First open: you should allow access for MTMR in Accessibility for correct buttons work like <kbd>Esc</kbd> Volume/Brightness and another system keys
|
||||
|
||||
## Troubleshooting
|
||||
If you can't open preferences:
|
||||
- Opening another program which can't edit text
|
||||
1. Open Terminal.app
|
||||
2. Put `open -a TextEdit ~/Library/Application\ Support/MTMR/items.json` command and press <kbd>Enter</kbd>
|
||||
|
||||
Buttons or gestures doesn't work:
|
||||
- "After the last update my mtmr is not working anymore!"
|
||||
- "Buttons sometimes do not trigger action"
|
||||
- "ESC don't work"
|
||||
- "Gestures don't work"
|
||||
|
||||
Re-tick or check a tick for access 🍏→ System Preferences → Security and Privacy → tab Privacy → Accessibility → MTMR
|
||||
|
||||
<img width="450" alt="screenshot 2019-02-24 at 23 19 20" src="https://user-images.githubusercontent.com/2198153/53307057-2b078200-388c-11e9-8212-8c2b1aff0aa6.png">
|
||||
|
||||
## Built-in button types:
|
||||
> Buttons
|
||||
- escape
|
||||
@@ -52,7 +70,9 @@ My idea is to create a platform for creating plugins to customize the TouchBar.
|
||||
- dock (half-long click to open app, full-long click to kill app)
|
||||
- nightShift
|
||||
- dnd (Don't disturb)
|
||||
- darkMode
|
||||
- pomodoro
|
||||
- network
|
||||
|
||||
> Media Keys
|
||||
- previous
|
||||
@@ -167,7 +187,16 @@ To close a group, use the button:
|
||||
{
|
||||
"type": "pomodoro",
|
||||
"workTime": 1200, // set time work in seconds. Default 1500 (25 min)
|
||||
"restTime": 600, // set time rest in seconds. Default 300 (5 min)
|
||||
"restTime": 600 // set time rest in seconds. Default 300 (5 min)
|
||||
},
|
||||
```
|
||||
|
||||
#### `network`
|
||||
> Network plugin. The plugin to show usage a network
|
||||
```js
|
||||
{
|
||||
"type": "network",
|
||||
"flip": true
|
||||
},
|
||||
```
|
||||
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
killall MTMR
|
||||
|
||||
NAME='MTMR'
|
||||
killall $NAME
|
||||
|
||||
rm -r Release 2>/dev/null
|
||||
|
||||
# xcodebuild \
|
||||
# -workspace ./MTMR.xcodeproj/project.xcworkspace \
|
||||
# -scheme MTMR \
|
||||
# -configuration Release CONFIGURATION_BUILD_DIR=./build/Release
|
||||
|
||||
xcodebuild archive \
|
||||
-scheme "$NAME" \
|
||||
-archivePath Release/App.xcarchive
|
||||
|
||||
xcodebuild \
|
||||
-workspace ./MTMR.xcodeproj/project.xcworkspace \
|
||||
-scheme MTMR \
|
||||
-configuration Release CONFIGURATION_BUILD_DIR=./build/Release
|
||||
-exportArchive \
|
||||
-archivePath Release/App.xcarchive \
|
||||
-exportOptionsPlist export-options.plist \
|
||||
-exportPath Release
|
||||
|
||||
open ./build/Release/MTMR.app
|
||||
cd Release
|
||||
rm -r App.xcarchive
|
||||
|
||||
# Prerequisite: npm i -g create-dmg
|
||||
NAME_DMG="${NAME}.app"
|
||||
echo $NAME_DMG
|
||||
create-dmg $NAME_DMG
|
||||
|
||||
open ./$NAME.app
|
||||
|
||||
Reference in New Issue
Block a user