40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
//
|
|
// AppDelegate.swift
|
|
// Underbar
|
|
//
|
|
// Created by Shadowfacts on 7/13/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
|
|
|
|
let rootController = RootTouchBarController()
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
|
|
statusBarItem.button!.image = NSImage(named: "underbar")!
|
|
|
|
let menu = NSMenu(title: "Underbar")
|
|
menu.addItem(NSMenuItem(title: "Quit Underbar", action: #selector(NSApp.terminate(_:)), keyEquivalent: "q"))
|
|
statusBarItem.menu = menu
|
|
|
|
NSTouchBar.presentSystemModalTouchBar(rootController.touchBar, placement: 1, systemTrayItemIdentifier: .underbar)
|
|
rootController.isVisible = true
|
|
DFRSystemModalShowsCloseBoxWhenFrontMost(false)
|
|
|
|
let systemItem = NSButtonTouchBarItem(identifier: .underbar, image: NSImage(named: "underbar")!, target: rootController, action: #selector(TouchBarController.toggle))
|
|
NSTouchBarItem.addSystemTrayItem(systemItem)
|
|
DFRElementSetControlStripPresenceForIdentifier(.underbar, true)
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
// Insert code here to tear down your application
|
|
}
|
|
|
|
}
|