diff --git a/Cartfile b/Cartfile index efb6a03..ce700bb 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,3 @@ github "sparkle-project/Sparkle" github "sindresorhus/Defaults" +github "sindresorhus/LaunchAtLogin" diff --git a/Cartfile.resolved b/Cartfile.resolved index 9cea8f0..4695e0f 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,3 @@ github "sindresorhus/Defaults" "v3.0.0" +github "sindresorhus/LaunchAtLogin" "v2.5.0" github "sparkle-project/Sparkle" "1.21.3" diff --git a/Touch Bar Simulator.xcodeproj/project.pbxproj b/Touch Bar Simulator.xcodeproj/project.pbxproj index 3ca35e8..3120721 100644 --- a/Touch Bar Simulator.xcodeproj/project.pbxproj +++ b/Touch Bar Simulator.xcodeproj/project.pbxproj @@ -10,6 +10,9 @@ 3C37035421FBEBD300177657 /* Defaults.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C37035321FBEBD300177657 /* Defaults.framework */; }; 3C37035521FBEBD300177657 /* Defaults.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3C37035321FBEBD300177657 /* Defaults.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 3C8493AD21FD3B7F00F12966 /* Glue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C8493AC21FD3B7F00F12966 /* Glue.swift */; }; + 3C906EEC231C5FB50099B139 /* LaunchAtLogin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C906EEB231C5FB50099B139 /* LaunchAtLogin.framework */; }; + 3C906EED231C5FB90099B139 /* LaunchAtLogin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C906EEB231C5FB50099B139 /* LaunchAtLogin.framework */; }; + 3C906EEE231C5FB90099B139 /* LaunchAtLogin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3C906EEB231C5FB50099B139 /* LaunchAtLogin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; AF6C7BC61E7FAF38004A27E0 /* ToolbarSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF6C7BC51E7FAF38004A27E0 /* ToolbarSlider.swift */; }; E30988DF1E88DD060078CA9E /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E30988DE1E88DD060078CA9E /* Sparkle.framework */; }; E30988E01E88DD060078CA9E /* Sparkle.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E30988DE1E88DD060078CA9E /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -35,6 +38,7 @@ files = ( E30988E01E88DD060078CA9E /* Sparkle.framework in Embed Frameworks */, E39A158B214D011F00F86D5D /* SkyLight.framework in Embed Frameworks */, + 3C906EEE231C5FB90099B139 /* LaunchAtLogin.framework in Embed Frameworks */, 3C37035521FBEBD300177657 /* Defaults.framework in Embed Frameworks */, E39A157F214CFE7100F86D5D /* DFRFoundation.framework in Embed Frameworks */, ); @@ -46,6 +50,7 @@ /* Begin PBXFileReference section */ 3C37035321FBEBD300177657 /* Defaults.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Defaults.framework; path = Carthage/Build/Mac/Defaults.framework; sourceTree = ""; }; 3C8493AC21FD3B7F00F12966 /* Glue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Glue.swift; sourceTree = ""; usesTabs = 1; }; + 3C906EEB231C5FB50099B139 /* LaunchAtLogin.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LaunchAtLogin.framework; path = Carthage/Build/Mac/LaunchAtLogin.framework; sourceTree = ""; }; AF6C7BC51E7FAF38004A27E0 /* ToolbarSlider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ToolbarSlider.swift; sourceTree = ""; usesTabs = 1; }; E30988DE1E88DD060078CA9E /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Carthage/Build/Mac/Sparkle.framework; sourceTree = ""; }; E34D6548214BBDAE00786C24 /* Touch Bar Simulator.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Touch Bar Simulator.entitlements"; sourceTree = ""; }; @@ -70,6 +75,8 @@ files = ( E39A157E214CFE7100F86D5D /* DFRFoundation.framework in Frameworks */, E39A158A214D011F00F86D5D /* SkyLight.framework in Frameworks */, + 3C906EED231C5FB90099B139 /* LaunchAtLogin.framework in Frameworks */, + 3C906EEC231C5FB50099B139 /* LaunchAtLogin.framework in Frameworks */, 3C37035421FBEBD300177657 /* Defaults.framework in Frameworks */, E30988DF1E88DD060078CA9E /* Sparkle.framework in Frameworks */, ); @@ -130,6 +137,7 @@ children = ( E30988DE1E88DD060078CA9E /* Sparkle.framework */, 3C37035321FBEBD300177657 /* Defaults.framework */, + 3C906EEB231C5FB50099B139 /* LaunchAtLogin.framework */, ); name = Frameworks; sourceTree = ""; @@ -146,6 +154,7 @@ E3FE2CBC1E726CE800C6713A /* Frameworks */, E3FE2CBD1E726CE800C6713A /* Resources */, E3FA3A901E784C5F00A7F2EA /* Embed Frameworks */, + 3C906EEF231C60060099B139 /* Copy Launch at Login Helper */, ); buildRules = ( ); @@ -209,6 +218,25 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 3C906EEF231C60060099B139 /* 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 = "\"${PROJECT_DIR}/Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh\"\n"; + showEnvVarsInLog = 0; + }; E3679C9A215A1ECA0080270F /* SwiftLint */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/Touch Bar Simulator/AppDelegate.swift b/Touch Bar Simulator/AppDelegate.swift index 080ba38..6173543 100644 --- a/Touch Bar Simulator/AppDelegate.swift +++ b/Touch Bar Simulator/AppDelegate.swift @@ -1,6 +1,7 @@ import Cocoa import Sparkle import Defaults +import LaunchAtLogin final class AppDelegate: NSObject, NSApplicationDelegate { lazy var window = with(TouchBarWindow()) { @@ -89,6 +90,11 @@ extension AppDelegate: NSMenuDelegate { menu.addItem(NSMenuItem("Hide and Show Automatically").bindState(to: .dockBehavior)) + menu.addItem(NSMenuItem("Launch at Login", isChecked: LaunchAtLogin.isEnabled) { item in + item.isChecked.toggle() + LaunchAtLogin.isEnabled = item.isChecked + }) + menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem("Quit Touch Bar Simulator", keyEquivalent: "q") { _ in