cleaned up after remove StatsLauncher

This commit is contained in:
Serhiy Mytrovtsiy
2019-09-04 21:22:30 +02:00
parent 019ee41c53
commit d38a2bf36d
3 changed files with 3 additions and 24 deletions

View File

@@ -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) {

View File

@@ -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>

View File

@@ -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: ""))