mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
53 lines
1.8 KiB
Swift
53 lines
1.8 KiB
Swift
//
|
|
// AppDelegate.swift
|
|
// MTMR
|
|
//
|
|
// Created by Anton Palgunov on 16/03/2018.
|
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength)
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
// Insert code here to initialize your application
|
|
TouchBarController.shared.setupControlStripPresence()
|
|
|
|
if let button = statusItem.button {
|
|
button.image = #imageLiteral(resourceName: "StatusImage")
|
|
}
|
|
createMenu()
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
// Insert code here to tear down your application
|
|
}
|
|
|
|
@objc func openPrefereces(_ sender: Any?) {
|
|
let task = Process()
|
|
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
|
let presetPath = appSupportDirectory.appending("/items.json")
|
|
task.launchPath = "/usr/bin/open"
|
|
task.arguments = [presetPath]
|
|
task.launch()
|
|
}
|
|
|
|
@objc func updatePreset(_ sender: Any?) {
|
|
TouchBarController.shared.createAndUpdatePreset()
|
|
}
|
|
|
|
func createMenu() {
|
|
let menu = NSMenu()
|
|
menu.addItem(withTitle: "Preferences", action: #selector(openPrefereces(_:)), keyEquivalent: ",")
|
|
menu.addItem(withTitle: "Reload Preset", action: #selector(updatePreset(_:)), keyEquivalent: "r")
|
|
menu.addItem(NSMenuItem.separator())
|
|
menu.addItem(withTitle: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
|
statusItem.menu = menu
|
|
}
|
|
|
|
}
|
|
|