diff --git a/Vitals.xcodeproj/project.pbxproj b/Vitals.xcodeproj/project.pbxproj index 69e01d9..cfdd7e6 100644 --- a/Vitals.xcodeproj/project.pbxproj +++ b/Vitals.xcodeproj/project.pbxproj @@ -3,12 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ 4A0AFDCA25B341E70096B015 /* Sparkline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A0AFDC925B341E70096B015 /* Sparkline.swift */; }; 4A0AFDD425B359690096B015 /* ProcessMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A0AFDD325B359690096B015 /* ProcessMonitor.swift */; }; + 4A10A18C260AC705004508F8 /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 4A10A18B260AC705004508F8 /* LaunchAtLogin */; }; 4A267B2125BB81F300530801 /* ProcessStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A267B2025BB81F300530801 /* ProcessStats.swift */; }; 4A267B2E25BB828700530801 /* ProcessStatsWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A267B2D25BB828700530801 /* ProcessStatsWindow.swift */; }; 4A602E4625B0FA8B008AFC7F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A602E4525B0FA8B008AFC7F /* AppDelegate.swift */; }; @@ -65,6 +66,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4A10A18C260AC705004508F8 /* LaunchAtLogin in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -160,12 +162,16 @@ 4A602E3E25B0FA8B008AFC7F /* Sources */, 4A602E3F25B0FA8B008AFC7F /* Frameworks */, 4A602E4025B0FA8B008AFC7F /* Resources */, + 4A41094F260ACCEB0041E834 /* Copy "Launch at Login Helper" */, ); buildRules = ( ); dependencies = ( ); name = Vitals; + packageProductDependencies = ( + 4A10A18B260AC705004508F8 /* LaunchAtLogin */, + ); productName = Vitals; productReference = 4A602E4225B0FA8B008AFC7F /* Vitals.app */; productType = "com.apple.product-type.application"; @@ -237,6 +243,9 @@ Base, ); mainGroup = 4A602E3925B0FA8B008AFC7F; + packageReferences = ( + 4A10A18A260AC705004508F8 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */, + ); productRefGroup = 4A602E4325B0FA8B008AFC7F /* Products */; projectDirPath = ""; projectRoot = ""; @@ -275,6 +284,27 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4A41094F260ACCEB0041E834 /* Copy "Launch at Login Helper" */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy \"Launch at Login Helper\""; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 4A602E3E25B0FA8B008AFC7F /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -466,7 +496,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 0.1; + MARKETING_VERSION = 0.2; PRODUCT_BUNDLE_IDENTIFIER = com.hmarr.Vitals; PRODUCT_NAME = "$(TARGET_NAME)"; "SWIFT_INCLUDE_PATHS[arch=*]" = "${SRCROOT}/**"; @@ -492,7 +522,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 0.1; + MARKETING_VERSION = 0.2; PRODUCT_BUNDLE_IDENTIFIER = com.hmarr.Vitals; PRODUCT_NAME = "$(TARGET_NAME)"; "SWIFT_INCLUDE_PATHS[arch=*]" = "${SRCROOT}/**"; @@ -624,6 +654,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 4A10A18A260AC705004508F8 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.1.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 4A10A18B260AC705004508F8 /* LaunchAtLogin */ = { + isa = XCSwiftPackageProductDependency; + package = 4A10A18A260AC705004508F8 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */; + productName = LaunchAtLogin; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 4A602E3A25B0FA8B008AFC7F /* Project object */; } diff --git a/Vitals.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Vitals.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..1f5ee3f --- /dev/null +++ b/Vitals.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "LaunchAtLogin", + "repositoryURL": "https://github.com/sindresorhus/LaunchAtLogin", + "state": { + "branch": null, + "revision": "6b16bcdf7d45a9d76a768a5c4912dde925cf0e95", + "version": "4.1.0" + } + } + ] + }, + "version": 1 +} diff --git a/Vitals/StatusBarController.swift b/Vitals/StatusBarController.swift index 2c01ee1..001470e 100644 --- a/Vitals/StatusBarController.swift +++ b/Vitals/StatusBarController.swift @@ -6,10 +6,12 @@ // import AppKit +import LaunchAtLogin class StatusBarController { private var statusBar: NSStatusBar private var statusItem: NSStatusItem + private var launchAtLoginItem: NSMenuItem private var popover: NSPopover private var contentViewModel: ContentViewModel private var clickMonitor: Any? @@ -22,6 +24,15 @@ class StatusBarController { statusItem = statusBar.statusItem(withLength: 28.0) let statusBarMenu = NSMenu(title: "Status Bar Menu") + + launchAtLoginItem = statusBarMenu.addItem( + withTitle: "Launch at Login", + action: #selector(toggleLaunchAtLogin(sender:)), + keyEquivalent: "" + ) + launchAtLoginItem.state = LaunchAtLogin.isEnabled ? .on : .off + launchAtLoginItem.target = self + let quitItem = statusBarMenu.addItem( withTitle: "Quit Vitals", action: #selector(quit(sender:)), @@ -68,6 +79,11 @@ class StatusBarController { NSApplication.shared.terminate(self) } + @objc func toggleLaunchAtLogin(sender: AnyObject) { + LaunchAtLogin.isEnabled = !LaunchAtLogin.isEnabled + launchAtLoginItem.state = LaunchAtLogin.isEnabled ? .on : .off + } + @objc func togglePopover(sender: AnyObject) { if popover.isShown { hidePopover(sender)