2019-07-26 20:38:19 -06:00
|
|
|
//
|
|
|
|
// AppDelegate.swift
|
|
|
|
// dotBeatBar_old
|
|
|
|
//
|
|
|
|
// Created by Aaron Bieber on 7/26/19.
|
|
|
|
// Copyright © 2019 Aaron Bieber. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2019-07-26 21:44:43 -06:00
|
|
|
import Beat
|
2019-07-27 08:49:55 -06:00
|
|
|
import Cocoa
|
2019-07-26 21:44:43 -06:00
|
|
|
import Foundation
|
2019-07-26 20:38:19 -06:00
|
|
|
|
|
|
|
@NSApplicationMain
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
2019-07-26 21:44:43 -06:00
|
|
|
var timer = Timer()
|
|
|
|
let si = NSStatusBar.system.statusItem(withLength:NSStatusItem.variableLength)
|
|
|
|
@objc func updateStatBar(_ sender: Any?) {
|
|
|
|
if let button = si.button {
|
|
|
|
button.title = "@\(Beat(Date().timeIntervalSince1970).text())"
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 20:38:19 -06:00
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
2019-07-26 21:44:43 -06:00
|
|
|
updateStatBar(self)
|
2019-07-27 08:49:55 -06:00
|
|
|
timer = Timer.scheduledTimer(timeInterval: 11,
|
|
|
|
target: self,
|
|
|
|
selector: #selector(updateStatBar),
|
|
|
|
userInfo: nil,
|
|
|
|
repeats: true)
|
2019-07-26 21:44:43 -06:00
|
|
|
|
|
|
|
let menu = NSMenu()
|
|
|
|
menu.addItem(NSMenuItem(title: "Quit", action:
|
|
|
|
#selector(NSApplication.terminate(_:)), keyEquivalent: "q"))
|
|
|
|
|
|
|
|
si.menu = menu
|
2019-07-26 20:38:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
|
|
// Insert code here to tear down your application
|
2019-07-26 21:44:43 -06:00
|
|
|
timer.invalidate()
|
2019-07-26 20:38:19 -06:00
|
|
|
}
|
|
|
|
}
|