This commit is contained in:
Serhiy Mytrovtsiy
2019-06-06 14:31:31 +02:00
parent e10db6aa21
commit 1045009b3f
5 changed files with 28 additions and 26 deletions

View File

@@ -7,6 +7,11 @@
//
import Cocoa
import ServiceManagement
extension Notification.Name {
static let killLauncher = Notification.Name("killLauncher")
}
let modules: Observable<[Module]> = Observable([CPU(), Memory(), Disk()])
let colors: Observable<Bool> = Observable(true)
@@ -24,6 +29,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
colors << (defaults.object(forKey: "colors") != nil ? defaults.bool(forKey: "colors") : false)
_ = MenuBar(menuBarItem, menuBarButton: menuBarButton)
let launcherAppId = "eu.exelban.Stats"
let runningApps = NSWorkspace.shared.runningApplications
let isRunning = !runningApps.filter { $0.bundleIdentifier == launcherAppId }.isEmpty
if isRunning {
DistributedNotificationCenter.default().post(name: .killLauncher, object: Bundle.main.bundleIdentifier!)
}
}
func applicationWillTerminate(_ aNotification: Notification) {

View File

@@ -19,7 +19,7 @@ protocol Module {
func stop()
}
extension Module where Self: Module {
extension Module {
func stop() {
self.reader.stop()
self.reader.usage.unsubscribe(observer: self as AnyObject)