mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
cleaned up after remove StatsLauncher
This commit is contained in:
@@ -9,16 +9,10 @@
|
||||
import Cocoa
|
||||
import ServiceManagement
|
||||
|
||||
extension Notification.Name {
|
||||
static let killLauncher = Notification.Name("killLauncher")
|
||||
}
|
||||
|
||||
let modules: Observable<[Module]> = Observable([CPU(), Memory(), Disk(), Battery(), Network()])
|
||||
let updater = macAppUpdater(user: "exelban", repo: "stats")
|
||||
let menu = NSPopover()
|
||||
|
||||
let appStoreMode: Bool = false
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
let defaults = UserDefaults.standard
|
||||
@@ -36,21 +30,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
_ = MenuBar(menuBarItem, menuBarButton: menuBarButton)
|
||||
|
||||
let launcherAppId = "eu.exelban.StatsLauncher"
|
||||
let runningApps = NSWorkspace.shared.runningApplications
|
||||
let isRunning = !runningApps.filter { $0.bundleIdentifier == launcherAppId }.isEmpty
|
||||
|
||||
if defaults.object(forKey: "runAtLogin") == nil {
|
||||
SMLoginItemSetEnabled(launcherAppId as CFString, true)
|
||||
self.defaults.set(true, forKey: "runAtLogin")
|
||||
}
|
||||
|
||||
if defaults.object(forKey: "dockIcon") != nil {
|
||||
let dockIconStatus = defaults.bool(forKey: "dockIcon") ? NSApplication.ActivationPolicy.regular : NSApplication.ActivationPolicy.accessory
|
||||
NSApp.setActivationPolicy(dockIconStatus)
|
||||
}
|
||||
|
||||
if !appStoreMode && defaults.object(forKey: "checkUpdatesOnLogin") == nil || defaults.bool(forKey: "checkUpdatesOnLogin") {
|
||||
if defaults.object(forKey: "checkUpdatesOnLogin") == nil || defaults.bool(forKey: "checkUpdatesOnLogin") {
|
||||
updater.check() { result, error in
|
||||
if error != nil && error as! String == "No internet connection" {
|
||||
return
|
||||
@@ -71,10 +56,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isRunning {
|
||||
DistributedNotificationCenter.default().post(name: .killLauncher, object: Bundle.main.bundleIdentifier!)
|
||||
}
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.3.0</string>
|
||||
<string>1.2.12</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
|
||||
@@ -121,9 +121,7 @@ class MainViewController: NSViewController {
|
||||
let aboutMenu = NSMenuItem(title: "About Stats", action: #selector(openAbout), keyEquivalent: "")
|
||||
aboutMenu.target = self
|
||||
|
||||
if !appStoreMode {
|
||||
menu.addItem(updateMenu)
|
||||
}
|
||||
menu.addItem(updateMenu)
|
||||
menu.addItem(aboutMenu)
|
||||
menu.addItem(NSMenuItem(title: "Quit Stats", action: #selector(NSApplication.terminate(_:)), keyEquivalent: ""))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user