mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
stash
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user