Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86a2f2f84c | ||
|
|
f24d24574a | ||
|
|
79607cb9f8 | ||
|
|
76492143c9 | ||
|
|
ee3890a10c | ||
|
|
ebeaf45d3a | ||
|
|
71f49f4b44 | ||
|
|
b6883556fa | ||
|
|
37bb2ecb3b | ||
|
|
376db25ff5 | ||
|
|
5daf000339 | ||
|
|
6fbaa1a5d8 | ||
|
|
1ed7fb8cb6 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
github "SwiftyJSON/SwiftyJSON" "5.0.0"
|
||||
github "acheronfail/MASShortcut" "2.3.6-custom"
|
||||
github "emaloney/CleanroomLogger" "6.0.2"
|
||||
github "sindresorhus/LaunchAtLogin" "v2.5.0"
|
||||
github "sindresorhus/LaunchAtLogin" "v4.0.0"
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
github: sindresorhus
|
||||
open_collective: sindresorhus
|
||||
patreon: sindresorhus
|
||||
custom: https://sindresorhus.com/donate
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -3,15 +3,18 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 51;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D92CFD2224C5D909005B91BE /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92CFD2124C5D909005B91BE /* Toggle.swift */; };
|
||||
D9EF7E1D24BCF9E300A1E9AA /* copy-helper-swiftpm.sh in Resources */ = {isa = PBXBuildFile; fileRef = D9EF7E1C24BCF9E300A1E9AA /* copy-helper-swiftpm.sh */; };
|
||||
E32E9B681EB87D7B000FEEE9 /* LaunchAtLogin.h in Headers */ = {isa = PBXBuildFile; fileRef = E32E9B661EB87D7B000FEEE9 /* LaunchAtLogin.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E32E9B6F1EB87DC5000FEEE9 /* LaunchAtLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = E32E9B6E1EB87DC5000FEEE9 /* LaunchAtLogin.swift */; };
|
||||
E32E9B771EB87EA3000FEEE9 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = E32E9B761EB87EA3000FEEE9 /* main.swift */; };
|
||||
E32E9B861EB8845E000FEEE9 /* LaunchAtLoginHelper.app in Resources */ = {isa = PBXBuildFile; fileRef = E32E9B741EB87EA3000FEEE9 /* LaunchAtLoginHelper.app */; };
|
||||
E32E9B931EB889AE000FEEE9 /* copy-helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = E32E9B921EB889AE000FEEE9 /* copy-helper.sh */; };
|
||||
E3A6EB58249009C3004D7101 /* LaunchAtLogin.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = E3A6EB57249009C3004D7101 /* LaunchAtLogin.entitlements */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -25,6 +28,8 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
D92CFD2124C5D909005B91BE /* Toggle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Toggle.swift; sourceTree = "<group>"; usesTabs = 1; };
|
||||
D9EF7E1C24BCF9E300A1E9AA /* copy-helper-swiftpm.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "copy-helper-swiftpm.sh"; sourceTree = "<group>"; };
|
||||
E32E9B631EB87D7B000FEEE9 /* LaunchAtLogin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LaunchAtLogin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E32E9B661EB87D7B000FEEE9 /* LaunchAtLogin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = LaunchAtLogin.h; sourceTree = "<group>"; usesTabs = 1; };
|
||||
E32E9B671EB87D7B000FEEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
@@ -33,6 +38,7 @@
|
||||
E32E9B761EB87EA3000FEEE9 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = main.swift; sourceTree = "<group>"; usesTabs = 1; };
|
||||
E32E9B7F1EB87EA3000FEEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
E32E9B921EB889AE000FEEE9 /* copy-helper.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; lineEnding = 0; path = "copy-helper.sh"; sourceTree = "<group>"; usesTabs = 1; };
|
||||
E3A6EB57249009C3004D7101 /* LaunchAtLogin.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LaunchAtLogin.entitlements; sourceTree = "<group>"; };
|
||||
E3B8C38A20C0003300272EC0 /* LaunchAtLoginHelper.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LaunchAtLoginHelper.entitlements; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -54,11 +60,19 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
E32E9B591EB87D7B000FEEE9 = {
|
||||
D9CFA59424C0FB5E005BC9E9 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E32E9B651EB87D7B000FEEE9 /* LaunchAtLogin */,
|
||||
E32E9B751EB87EA3000FEEE9 /* LaunchAtLoginHelper */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E32E9B591EB87D7B000FEEE9 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D9CFA59424C0FB5E005BC9E9 /* Sources */,
|
||||
E32E9B641EB87D7B000FEEE9 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
@@ -76,10 +90,13 @@
|
||||
E32E9B651EB87D7B000FEEE9 /* LaunchAtLogin */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E32E9B6E1EB87DC5000FEEE9 /* LaunchAtLogin.swift */,
|
||||
E32E9B661EB87D7B000FEEE9 /* LaunchAtLogin.h */,
|
||||
D9EF7E1C24BCF9E300A1E9AA /* copy-helper-swiftpm.sh */,
|
||||
E32E9B921EB889AE000FEEE9 /* copy-helper.sh */,
|
||||
E32E9B671EB87D7B000FEEE9 /* Info.plist */,
|
||||
E3A6EB57249009C3004D7101 /* LaunchAtLogin.entitlements */,
|
||||
E32E9B661EB87D7B000FEEE9 /* LaunchAtLogin.h */,
|
||||
E32E9B6E1EB87DC5000FEEE9 /* LaunchAtLogin.swift */,
|
||||
D92CFD2124C5D909005B91BE /* Toggle.swift */,
|
||||
);
|
||||
path = LaunchAtLogin;
|
||||
sourceTree = "<group>";
|
||||
@@ -151,16 +168,16 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0830;
|
||||
LastUpgradeCheck = 0940;
|
||||
LastUpgradeCheck = 1200;
|
||||
ORGANIZATIONNAME = "Sindre Sorhus";
|
||||
TargetAttributes = {
|
||||
E32E9B621EB87D7B000FEEE9 = {
|
||||
CreatedOnToolsVersion = 8.3.2;
|
||||
LastSwiftMigration = "";
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
E32E9B731EB87EA3000FEEE9 = {
|
||||
CreatedOnToolsVersion = 8.3.2;
|
||||
LastSwiftMigration = "";
|
||||
LastSwiftMigration = 1020;
|
||||
SystemCapabilities = {
|
||||
com.apple.HardenedRuntime = {
|
||||
enabled = 1;
|
||||
@@ -173,8 +190,8 @@
|
||||
};
|
||||
};
|
||||
buildConfigurationList = E32E9B5D1EB87D7B000FEEE9 /* Build configuration list for PBXProject "LaunchAtLogin" */;
|
||||
compatibilityVersion = "Xcode 10.0";
|
||||
developmentRegion = English;
|
||||
compatibilityVersion = "Xcode 12.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
@@ -198,6 +215,8 @@
|
||||
files = (
|
||||
E32E9B861EB8845E000FEEE9 /* LaunchAtLoginHelper.app in Resources */,
|
||||
E32E9B931EB889AE000FEEE9 /* copy-helper.sh in Resources */,
|
||||
D9EF7E1D24BCF9E300A1E9AA /* copy-helper-swiftpm.sh in Resources */,
|
||||
E3A6EB58249009C3004D7101 /* LaunchAtLogin.entitlements in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -216,6 +235,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
E32E9B6F1EB87DC5000FEEE9 /* LaunchAtLogin.swift in Sources */,
|
||||
D92CFD2224C5D909005B91BE /* Toggle.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -263,6 +283,7 @@
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
@@ -295,7 +316,7 @@
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_COMPILATION_MODE = singlefile;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
VALID_ARCHS = x86_64;
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
@@ -326,6 +347,7 @@
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
@@ -350,7 +372,7 @@
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALID_ARCHS = x86_64;
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
@@ -364,25 +386,25 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = YG56YK5RN5;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = LaunchAtLogin/Info.plist;
|
||||
INFOPLIST_FILE = Sources/LaunchAtLogin/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 4.0.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.sindresorhus.LaunchAtLogin;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_COMPILATION_MODE = singlefile;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -394,36 +416,36 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = YG56YK5RN5;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = LaunchAtLogin/Info.plist;
|
||||
INFOPLIST_FILE = Sources/LaunchAtLogin/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 4.0.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.sindresorhus.LaunchAtLogin;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
E32E9B811EB87EA3000FEEE9 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = LaunchAtLoginHelper/LaunchAtLoginHelper.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
CODE_SIGN_ENTITLEMENTS = Sources/LaunchAtLoginHelper/LaunchAtLoginHelper.entitlements;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = YG56YK5RN5;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = LaunchAtLoginHelper/Info.plist;
|
||||
INFOPLIST_FILE = Sources/LaunchAtLoginHelper/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
@@ -432,20 +454,19 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
E32E9B821EB87EA3000FEEE9 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = LaunchAtLoginHelper/LaunchAtLoginHelper.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Mac Developer";
|
||||
CODE_SIGN_ENTITLEMENTS = Sources/LaunchAtLoginHelper/LaunchAtLoginHelper.entitlements;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = YG56YK5RN5;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = LaunchAtLoginHelper/Info.plist;
|
||||
INFOPLIST_FILE = Sources/LaunchAtLoginHelper/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
@@ -454,7 +475,6 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0940"
|
||||
LastUpgradeVersion = "1200"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -29,8 +29,6 @@
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -51,8 +49,6 @@
|
||||
ReferencedContainer = "container:LaunchAtLogin.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
+3
-7
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0940"
|
||||
LastUpgradeVersion = "1200"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -27,8 +27,6 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
@@ -38,8 +36,8 @@
|
||||
ReferencedContainer = "container:LaunchAtLogin.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -61,8 +59,6 @@
|
||||
ReferencedContainer = "container:LaunchAtLogin.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// swift-tools-version:5.3
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "LaunchAtLogin",
|
||||
platforms: [
|
||||
.macOS(.v10_12)
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "LaunchAtLogin",
|
||||
targets: ["LaunchAtLogin"]
|
||||
)
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "LaunchAtLogin",
|
||||
exclude: [
|
||||
"Info.plist",
|
||||
"copy-helper.sh"
|
||||
],
|
||||
resources: [
|
||||
.copy("LaunchAtLogin.entitlements"),
|
||||
.copy("copy-helper-swiftpm.sh"),
|
||||
.copy("LaunchAtLoginHelper.zip"),
|
||||
.copy("LaunchAtLoginHelper-with-runtime.zip")
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>MIT © Sindre Sorhus</string>
|
||||
</dict>
|
||||
</plist>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,4 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
FOUNDATION_EXPORT double LaunchAtLoginVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char LaunchAtLoginVersionString[];
|
||||
@@ -0,0 +1,67 @@
|
||||
import Foundation
|
||||
import ServiceManagement
|
||||
import Combine
|
||||
|
||||
public enum LaunchAtLogin {
|
||||
public static let kvo = KVO()
|
||||
|
||||
@available(macOS 10.15, *)
|
||||
public static let observable = Observable()
|
||||
|
||||
@available(macOS 10.15, *)
|
||||
private static var _publisher = CurrentValueSubject<Bool, Never>(isEnabled)
|
||||
@available(macOS 10.15, *)
|
||||
public static var publisher = _publisher.eraseToAnyPublisher()
|
||||
|
||||
private static let id = "\(Bundle.main.bundleIdentifier!)-LaunchAtLoginHelper"
|
||||
|
||||
public static var isEnabled: Bool {
|
||||
get {
|
||||
guard let jobs = (SMCopyAllJobDictionaries(kSMDomainUserLaunchd).takeRetainedValue() as? [[String: AnyObject]]) else {
|
||||
return false
|
||||
}
|
||||
|
||||
let job = jobs.first { $0["Label"] as! String == id }
|
||||
|
||||
return job?["OnDemand"] as? Bool ?? false
|
||||
}
|
||||
set {
|
||||
if #available(macOS 10.15, *) {
|
||||
observable.objectWillChange.send()
|
||||
}
|
||||
|
||||
kvo.willChangeValue(for: \.isEnabled)
|
||||
SMLoginItemSetEnabled(id as CFString, newValue)
|
||||
kvo.didChangeValue(for: \.isEnabled)
|
||||
|
||||
if #available(macOS 10.15, *) {
|
||||
_publisher.send(newValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - LaunchAtLoginObservable
|
||||
extension LaunchAtLogin {
|
||||
@available(macOS 10.15, *)
|
||||
public final class Observable: ObservableObject {
|
||||
public var isEnabled: Bool {
|
||||
get { LaunchAtLogin.isEnabled }
|
||||
set {
|
||||
LaunchAtLogin.isEnabled = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - LaunchAtLoginKVO
|
||||
extension LaunchAtLogin {
|
||||
public final class KVO: NSObject {
|
||||
@objc dynamic public var isEnabled: Bool {
|
||||
get { LaunchAtLogin.isEnabled }
|
||||
set {
|
||||
LaunchAtLogin.isEnabled = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import SwiftUI
|
||||
|
||||
@available(macOS 10.15, *)
|
||||
extension LaunchAtLogin {
|
||||
/**
|
||||
This package comes with a `LaunchAtLogin.Toggle` view which is like the built-in `Toggle` but with a predefined binding and label. Clicking the view toggles “launch at login” for your app.
|
||||
|
||||
```
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
LaunchAtLogin.Toggle()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The default label is `"Launch at login"`, but it can be overridden for localization and other needs:
|
||||
|
||||
```
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
LaunchAtLogin.Toggle {
|
||||
Text("Launch at login")
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
*/
|
||||
public struct Toggle<Label>: View where Label: View {
|
||||
@ObservedObject private var launchAtLogin = LaunchAtLogin.observable
|
||||
private let label: Label
|
||||
|
||||
/**
|
||||
Creates a toggle that displays a custom label.
|
||||
|
||||
- Parameters:
|
||||
- label: A view that describes the purpose of the toggle.
|
||||
*/
|
||||
public init(@ViewBuilder label: () -> Label) {
|
||||
self.label = label()
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
SwiftUI.Toggle(isOn: $launchAtLogin.isEnabled) { label }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15, *)
|
||||
extension LaunchAtLogin.Toggle where Label == Text {
|
||||
/**
|
||||
Creates a toggle that generates its label from a localized string key.
|
||||
|
||||
This initializer creates a ``Text`` view on your behalf with provided `titleKey`
|
||||
|
||||
- Parameters:
|
||||
- titleKey: The key for the toggle's localized title, that describes the purpose of the toggle.
|
||||
*/
|
||||
public init(_ titleKey: LocalizedStringKey) {
|
||||
label = Text(titleKey)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a toggle that generates its label from a string.
|
||||
|
||||
This initializer creates a `Text` view on your behalf with the provided `title`.
|
||||
|
||||
- Parameters:
|
||||
- title: A string that describes the purpose of the toggle.
|
||||
*/
|
||||
public init<S>(_ title: S) where S: StringProtocol {
|
||||
label = Text(title)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a toggle with the default title of `Launch at login`.
|
||||
*/
|
||||
public init() {
|
||||
self.init("Launch at login")
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
HELPER_CHECKSUM="6eaaced9173120f82ef98452b2d8cb3705c12db39d4286c70c4f5bb6b67a5e43"
|
||||
HELPER_CHECKSUM_RUNTIME="c5a48f5ba681088aa7922b79f2f1b55a1a006904b8de378790eb0e8b0ac66234"
|
||||
|
||||
verlte() {
|
||||
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
|
||||
}
|
||||
|
||||
if verlte "10.14.4" "$MACOSX_DEPLOYMENT_TARGET"; then
|
||||
helper_name="LaunchAtLoginHelper"
|
||||
checksum="$HELPER_CHECKSUM"
|
||||
else
|
||||
helper_name="LaunchAtLoginHelper-with-runtime"
|
||||
checksum="$HELPER_CHECKSUM_RUNTIME"
|
||||
fi
|
||||
|
||||
package_resources_path="$BUILT_PRODUCTS_DIR/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources"
|
||||
|
||||
helper_path="$package_resources_path/$helper_name.zip"
|
||||
|
||||
contents_path="$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH"
|
||||
login_items="$contents_path/Library/LoginItems"
|
||||
login_helper_path="$login_items/LaunchAtLoginHelper.app"
|
||||
|
||||
rm -rf "$login_helper_path"
|
||||
mkdir -p "$login_items"
|
||||
|
||||
# Verify SHA256 checksum of LaunchAtLoginHelper.
|
||||
zip_checksum="$(shasum -a 256 "$helper_path" | awk '{print $1}')"
|
||||
|
||||
if [[ "$zip_checksum" != "$checksum" ]]; then
|
||||
echo "Wrong checksum of LaunchAtLoginHelper"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unzip "$helper_path" -d "$login_items/"
|
||||
|
||||
defaults write "$login_helper_path/Contents/Info" CFBundleIdentifier -string "$PRODUCT_BUNDLE_IDENTIFIER-LaunchAtLoginHelper"
|
||||
|
||||
if [[ -n $CODE_SIGN_ENTITLEMENTS ]]; then
|
||||
codesign --force --entitlements="$package_resources_path/LaunchAtLogin.entitlements" --options=runtime --sign="$EXPANDED_CODE_SIGN_IDENTITY_NAME" "$login_helper_path"
|
||||
else
|
||||
codesign --force --options=runtime --sign="$EXPANDED_CODE_SIGN_IDENTITY_NAME" "$helper_path"
|
||||
fi
|
||||
|
||||
if [[ $CONFIGURATION == "Release" ]]; then
|
||||
rm -rf "$contents_path/Resources/LaunchAtLogin_LaunchAtLogin.bundle"
|
||||
fi
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
origin_helper_path="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/LaunchAtLogin.framework/Resources/LaunchAtLoginHelper.app"
|
||||
helper_dir="$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Library/LoginItems"
|
||||
helper_path="$helper_dir/LaunchAtLoginHelper.app"
|
||||
|
||||
rm -rf "$helper_path"
|
||||
mkdir -p "$helper_dir"
|
||||
cp -rf "$origin_helper_path" "$helper_dir/"
|
||||
|
||||
defaults write "$helper_path/Contents/Info" CFBundleIdentifier -string "$PRODUCT_BUNDLE_IDENTIFIER-LaunchAtLoginHelper"
|
||||
|
||||
if [[ -n $CODE_SIGN_ENTITLEMENTS ]]; then
|
||||
codesign --force --entitlements="$(dirname "$origin_helper_path")/LaunchAtLogin.entitlements" --options=runtime --sign="$EXPANDED_CODE_SIGN_IDENTITY_NAME" "$helper_path"
|
||||
else
|
||||
codesign --force --options=runtime --sign="$EXPANDED_CODE_SIGN_IDENTITY_NAME" "$helper_path"
|
||||
fi
|
||||
|
||||
if [[ $CONFIGURATION == "Release" ]]; then
|
||||
rm -rf "$origin_helper_path"
|
||||
rm "$(dirname "$origin_helper_path")/copy-helper.sh"
|
||||
rm "$(dirname "$origin_helper_path")/LaunchAtLogin.entitlements"
|
||||
fi
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
<true/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>MIT © Sindre Sorhus</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,25 @@
|
||||
import Cocoa
|
||||
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
let bundleId = Bundle.main.bundleIdentifier!
|
||||
// TODO: Make this more strict by only replacing at the end
|
||||
let mainBundleId = bundleId.replacingOccurrences(of: "-LaunchAtLoginHelper", with: "")
|
||||
|
||||
// Ensure the app is not already running
|
||||
guard NSRunningApplication.runningApplications(withBundleIdentifier: mainBundleId).isEmpty else {
|
||||
NSApp.terminate(nil)
|
||||
return
|
||||
}
|
||||
|
||||
let pathComponents = (Bundle.main.bundlePath as NSString).pathComponents
|
||||
let mainPath = NSString.path(withComponents: Array(pathComponents[0...(pathComponents.count - 5)]))
|
||||
NSWorkspace.shared.launchApplication(mainPath)
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
}
|
||||
|
||||
private let app = NSApplication.shared
|
||||
private let delegate = AppDelegate()
|
||||
app.delegate = delegate
|
||||
app.run()
|
||||
+148
-32
@@ -1,57 +1,58 @@
|
||||
# LaunchAtLogin
|
||||
|
||||
> Add "Launch at Login" functionality to your macOS app in seconds
|
||||
> Add “Launch at Login” functionality to your macOS app in seconds
|
||||
|
||||
It's usually quite a [convoluted and error-prone process](before-after.md) to add this. **No more!**
|
||||
|
||||
This package works with both sandboxed and non-sandboxed apps and it's App Store compatible and used in my [Lungo](https://blog.sindresorhus.com/lungo-b364a6c2745f) and [Battery Indicator](https://sindresorhus.com/battery-indicator) apps.
|
||||
|
||||
*You might also find my [`create-dmg`](https://github.com/sindresorhus/create-dmg) project useful if you're publishing your app outside the App Store.*
|
||||
|
||||
This package works with both sandboxed and non-sandboxed apps and it's App Store compatible and used in apps like [Plash](https://github.com/sindresorhus/Plash), [Dato](https://sindresorhus.com/dato), [Lungo](https://sindresorhus.com/lungo), and [Battery Indicator](https://sindresorhus.com/battery-indicator).
|
||||
|
||||
## Requirements
|
||||
|
||||
- macOS 10.12+
|
||||
- Xcode 10+
|
||||
- Swift 4.2+
|
||||
|
||||
- Xcode 12+
|
||||
- Swift 5.3+
|
||||
|
||||
## Install
|
||||
|
||||
#### Swift Package Manager
|
||||
|
||||
Xcode 12+ required.
|
||||
|
||||
```
|
||||
.package(url: "https://github.com/sindresorhus/LaunchAtLogin", from: "4.0.0")
|
||||
```
|
||||
|
||||
#### Carthage
|
||||
|
||||
*Warning: Carthage is not recommended. Support for it will be removed at some point in the future.*
|
||||
|
||||
```
|
||||
github "sindresorhus/LaunchAtLogin"
|
||||
```
|
||||
|
||||
#### CocoaPods
|
||||
|
||||
```ruby
|
||||
pod 'LaunchAtLogin'
|
||||
```
|
||||
|
||||
<a href="https://www.patreon.com/sindresorhus">
|
||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
||||
</a>
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Add a new ["Run Script Phase"](http://stackoverflow.com/a/39633955/64949) below "Embed Frameworks" in "Build Phases" with the following:
|
||||
Add a new ["Run Script Phase"](http://stackoverflow.com/a/39633955/64949) **below** "Embed Frameworks" in "Build Phases" with the following:
|
||||
|
||||
Carthage:
|
||||
#### Swift Package Manager
|
||||
|
||||
```sh
|
||||
"${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh"
|
||||
```
|
||||
|
||||
#### Carthage
|
||||
|
||||
```sh
|
||||
"${PROJECT_DIR}/Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh"
|
||||
```
|
||||
|
||||
CocoaPods:
|
||||
### Use it in your app
|
||||
|
||||
```sh
|
||||
"${PROJECT_DIR}/Pods/LaunchAtLogin/LaunchAtLogin/copy-helper.sh"
|
||||
```
|
||||
No need to store any state to UserDefaults.
|
||||
|
||||
Use it in your app:
|
||||
*Note that the [Mac App Store guidelines](https://developer.apple.com/app-store/review/guidelines/) requires “launch at login” functionality to be enabled in response to a user action. This is usually solved by making it a preference that is disabled by default. Many apps also let the user activate it in a welcome screen.*
|
||||
|
||||
#### As static property
|
||||
|
||||
```swift
|
||||
import LaunchAtLogin
|
||||
@@ -65,22 +66,137 @@ print(LaunchAtLogin.isEnabled)
|
||||
//=> true
|
||||
```
|
||||
|
||||
*Note that the [Mac App Store guidelines](https://developer.apple.com/app-store/review/guidelines/) requires "launch at login" functionality to be enabled in response to a user action. This is usually solved by making it a preference that is disabled by default.*
|
||||
#### SwiftUI
|
||||
|
||||
This package comes with a `LaunchAtLogin.Toggle` view which is like the built-in `Toggle` but with a predefined binding and label. Clicking the view toggles “launch at login” for your app.
|
||||
|
||||
```swift
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
LaunchAtLogin.Toggle()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The default label is `"Launch at login"`, but it can be overridden for localization and other needs:
|
||||
|
||||
```swift
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
LaunchAtLogin.Toggle {
|
||||
Text("Launch at login")
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, you can use `LaunchAtLogin.observable` as a binding with `@ObservedObject`:
|
||||
|
||||
```swift
|
||||
import SwiftUI
|
||||
import LaunchAtLogin
|
||||
|
||||
struct ContentView: View {
|
||||
@ObservedObject private var launchAtLogin = LaunchAtLogin.observable
|
||||
|
||||
var body: some View {
|
||||
Toggle("Launch at login", isOn: $launchAtLogin.isEnabled)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Combine
|
||||
|
||||
Just subscribe to `LaunchAtLogin.publisher`:
|
||||
|
||||
```swift
|
||||
import Combine
|
||||
import LaunchAtLogin
|
||||
|
||||
final class ViewModel {
|
||||
private var isLaunchAtLoginEnabled = LaunchAtLogin.isEnabled
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
func bind() {
|
||||
LaunchAtLogin
|
||||
.publisher
|
||||
.assign(to: \.isLaunchAtLoginEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Storyboards
|
||||
|
||||
Bind the control to the `LaunchAtLogin.kvo` exposed property:
|
||||
|
||||
```swift
|
||||
import Cocoa
|
||||
import LaunchAtLogin
|
||||
|
||||
final class ViewController: NSViewController {
|
||||
@objc dynamic var launchAtLogin = LaunchAtLogin.kvo
|
||||
}
|
||||
```
|
||||
|
||||
<img src="storyboard-binding.png" width="445">
|
||||
|
||||
## How does it work?
|
||||
|
||||
The framework bundles the helper app needed to launch your app and copies it into your app at build time.
|
||||
|
||||
## FAQ
|
||||
|
||||
#### I'm getting a “No such file or directory” error when archiving my app
|
||||
|
||||
Please ensure that the LaunchAtLogin run script phase is still below the “Embed Frameworks” phase. The order could have been accidentally changed.
|
||||
|
||||
The build error usually presents itself as:
|
||||
|
||||
```
|
||||
cp: […]/Resources/LaunchAtLoginHelper.app: No such file or directory
|
||||
rm: […]/Resources/copy-helper.sh: No such file or directory
|
||||
Command PhaseScriptExecution failed with a nonzero exit code
|
||||
```
|
||||
|
||||
#### The size of my app increased after adding `LaunchAtLogin` when using Carthage
|
||||
|
||||
The bundled launcher app is written in Swift and hence needs to embed the Swift runtime libraries. If your project targets macOS 10.14.4 or later, you can avoid embedding the Swift runtime libraries. First, open `./Carthage/Checkouts/LaunchAtLogin/LaunchAtLogin.xcodeproj` and set the deployment target to the same as your app, and then run `$ carthage build`. You'll have to do this each time you update `LaunchAtLogin`.
|
||||
|
||||
This is not a problem when using Swift Package Manager.
|
||||
|
||||
#### My app doesn't show up in “System Preferences › Users & Groups › Login Items”
|
||||
|
||||
[This is the expected behavior](https://stackoverflow.com/a/15104481/64949), unfortunately.
|
||||
|
||||
#### My app doesn't launch at login when testing
|
||||
|
||||
This is usually caused by having one or more older builds of your app laying around somewhere on the system, and macOS picking one of those instead, which doesn't have the launch helper, and thus fails to start.
|
||||
|
||||
Some things you can try:
|
||||
- Bump the version & build of your app so macOS is more likely to pick it.
|
||||
- Delete the [`DerivedData` directory](https://mgrebenets.github.io/mobile%20ci/2015/02/01/xcode-derived-data).
|
||||
- Ensure you don't have any other builds laying around somewhere.
|
||||
|
||||
Some helpful Stack Overflow answers:
|
||||
- https://stackoverflow.com/a/43281810/64949
|
||||
- https://stackoverflow.com/a/51683190/64949
|
||||
- https://stackoverflow.com/a/53110832/64949
|
||||
- https://stackoverflow.com/a/53110852/64949
|
||||
|
||||
#### Can you support CocoaPods?
|
||||
|
||||
CocoaPods used to be supported, but [it did not work well](https://github.com/sindresorhus/LaunchAtLogin/issues/22) and there was no easy way to fix it, so support was dropped. Even though you mainly use CocoaPods, you can still use Carthage just for this package without any problems.
|
||||
|
||||
#### I'm getting a `'SMCopyAllJobDictionaries' was deprecated in OS X 10.10` warning
|
||||
|
||||
Apple deprecated that API without providing an alternative. Apple engineers have [stated that it's still the preferred API to use](https://github.com/alexzielenski/StartAtLoginController/issues/12#issuecomment-307525807). I plan to use it as long as it's available. There are workarounds I can implement if Apple ever removes the API, so rest assured, this module will be made to work even then. If you want to see this resolved, submit a [Feedback Assistant](https://feedbackassistant.apple.com) report with [the following text](https://github.com/feedback-assistant/reports/issues/16). There's unfortunately still [no way to suppress warnings in Swift](https://stackoverflow.com/a/32861678/64949).
|
||||
|
||||
## Related
|
||||
|
||||
- [Defaults](https://github.com/sindresorhus/Defaults) - Swifty and modern UserDefaults
|
||||
- [Preferences](https://github.com/sindresorhus/Preferences) - Add a preferences window to your macOS app in minutes
|
||||
- [KeyboardShortcuts](https://github.com/sindresorhus/KeyboardShortcuts) - Add user-customizable global keyboard shortcuts to your macOS app
|
||||
- [DockProgress](https://github.com/sindresorhus/DockProgress) - Show progress in your app's Dock icon
|
||||
- [create-dmg](https://github.com/sindresorhus/create-dmg) - Create a good-looking DMG for your macOS app in seconds
|
||||
- [More…](https://github.com/search?q=user%3Asindresorhus+language%3Aswift)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -31,13 +31,12 @@
|
||||
BA74C14E20ADA33E00306B27 /* PPColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA74C14D20ADA33E00306B27 /* PPColor.swift */; };
|
||||
BAA17B7320B14CC100625455 /* LaunchAtLogin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B6F20B14CC000625455 /* LaunchAtLogin.framework */; };
|
||||
BAA17B7420B14CC100625455 /* LaunchAtLogin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B6F20B14CC000625455 /* LaunchAtLogin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
BAA17B7720B14CC100625455 /* CleanroomLogger.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B7120B14CC000625455 /* CleanroomLogger.framework */; };
|
||||
BAA17B7820B14CC100625455 /* CleanroomLogger.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B7120B14CC000625455 /* CleanroomLogger.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
BAA17B7920B14CC100625455 /* MASShortcut.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B7220B14CC100625455 /* MASShortcut.framework */; };
|
||||
BAA17B7A20B14CC100625455 /* MASShortcut.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B7220B14CC100625455 /* MASShortcut.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
BAA17B7C20B14CEB00625455 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B7B20B14CEB00625455 /* SwiftyJSON.framework */; };
|
||||
BAA17B7D20B14CEB00625455 /* SwiftyJSON.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BAA17B7B20B14CEB00625455 /* SwiftyJSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
BAB6F14F221ABB3500EA11D4 /* ShowAndHideCursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB6F14E221ABB3500EA11D4 /* ShowAndHideCursor.swift */; };
|
||||
D62EACF22465996700686344 /* WCAG.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62EACF12465996700686344 /* WCAG.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -58,7 +57,6 @@
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
BAA17B7D20B14CEB00625455 /* SwiftyJSON.framework in Embed Frameworks */,
|
||||
BAA17B7820B14CC100625455 /* CleanroomLogger.framework in Embed Frameworks */,
|
||||
BAA17B7A20B14CC100625455 /* MASShortcut.framework in Embed Frameworks */,
|
||||
BAA17B7420B14CC100625455 /* LaunchAtLogin.framework in Embed Frameworks */,
|
||||
);
|
||||
@@ -98,10 +96,10 @@
|
||||
BA74C14320AA609500306B27 /* PPOverlayWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PPOverlayWrapper.swift; sourceTree = "<group>"; };
|
||||
BA74C14D20ADA33E00306B27 /* PPColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PPColor.swift; sourceTree = "<group>"; };
|
||||
BAA17B6F20B14CC000625455 /* LaunchAtLogin.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LaunchAtLogin.framework; path = Carthage/Build/Mac/LaunchAtLogin.framework; sourceTree = "<group>"; };
|
||||
BAA17B7120B14CC000625455 /* CleanroomLogger.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CleanroomLogger.framework; path = Carthage/Build/Mac/CleanroomLogger.framework; sourceTree = "<group>"; };
|
||||
BAA17B7220B14CC100625455 /* MASShortcut.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MASShortcut.framework; path = Carthage/Build/Mac/MASShortcut.framework; sourceTree = "<group>"; };
|
||||
BAA17B7B20B14CEB00625455 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = Carthage/Build/Mac/SwiftyJSON.framework; sourceTree = "<group>"; };
|
||||
BAB6F14E221ABB3500EA11D4 /* ShowAndHideCursor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowAndHideCursor.swift; sourceTree = "<group>"; };
|
||||
D62EACF12465996700686344 /* WCAG.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCAG.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -118,7 +116,6 @@
|
||||
files = (
|
||||
BAA17B7920B14CC100625455 /* MASShortcut.framework in Frameworks */,
|
||||
BAA17B7320B14CC100625455 /* LaunchAtLogin.framework in Frameworks */,
|
||||
BAA17B7720B14CC100625455 /* CleanroomLogger.framework in Frameworks */,
|
||||
BA22232720AFEC1B0001069C /* ApplicationServices.framework in Frameworks */,
|
||||
BAA17B7C20B14CEB00625455 /* SwiftyJSON.framework in Frameworks */,
|
||||
);
|
||||
@@ -154,7 +151,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BAA17B7B20B14CEB00625455 /* SwiftyJSON.framework */,
|
||||
BAA17B7120B14CC000625455 /* CleanroomLogger.framework */,
|
||||
BAA17B6F20B14CC000625455 /* LaunchAtLogin.framework */,
|
||||
BAA17B7220B14CC100625455 /* MASShortcut.framework */,
|
||||
15FF0CCC204A231800E04103 /* Bridging-Header.h */,
|
||||
@@ -191,6 +187,7 @@
|
||||
15349DB720BAE3F70071CAA1 /* NSBezierPath.swift */,
|
||||
BA74C14120AA409D00306B27 /* NSColor.swift */,
|
||||
15492102207B53AE00E45BBC /* Util.swift */,
|
||||
D62EACF12465996700686344 /* WCAG.swift */,
|
||||
B3B4C2C21E25894B009F8E4E /* Assets.xcassets */,
|
||||
BA22232A20B0E3B50001069C /* README.md */,
|
||||
155D2C02204F61220087478B /* Credits.rtfd */,
|
||||
@@ -349,6 +346,7 @@
|
||||
BA22232920B04D660001069C /* AppDelegate+Menu.swift in Sources */,
|
||||
BA74C14E20ADA33E00306B27 /* PPColor.swift in Sources */,
|
||||
15FC8CC8204E2E2C000B5E1E /* PPState.swift in Sources */,
|
||||
D62EACF22465996700686344 /* WCAG.swift in Sources */,
|
||||
BA74C13120A6E95900306B27 /* PPOverlayPanel.swift in Sources */,
|
||||
BA74C14020AA390400306B27 /* PPOverlayPreview.swift in Sources */,
|
||||
BA74C14420AA609500306B27 /* PPOverlayWrapper.swift in Sources */,
|
||||
@@ -553,6 +551,7 @@
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 18;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -562,6 +561,7 @@
|
||||
INFOPLIST_FILE = "Pixel Picker/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MARKETING_VERSION = 1.4.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.acheronfail.pixel-picker";
|
||||
PRODUCT_MODULE_NAME = PixelPicker;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -579,6 +579,7 @@
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 18;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -588,6 +589,7 @@
|
||||
INFOPLIST_FILE = "Pixel Picker/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
MARKETING_VERSION = 1.4.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.acheronfail.pixel-picker";
|
||||
PRODUCT_MODULE_NAME = PixelPicker;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
@@ -99,6 +99,7 @@ extension AppDelegate: NSMenuDelegate {
|
||||
buildShortcutMenuItem()
|
||||
buildUseUppercaseItem()
|
||||
buildLaunchAtLoginItem()
|
||||
buildShowWCAGItem()
|
||||
|
||||
contextMenu.addItem(.separator())
|
||||
contextMenu.addItem(withTitle: "About", action: #selector(showAboutPanel), keyEquivalent: "")
|
||||
@@ -201,6 +202,15 @@ extension AppDelegate: NSMenuDelegate {
|
||||
let item = contextMenu.addItem(withTitle: "Launch \(APP_NAME) at Login", action: #selector(launchAtLogin(_:)), keyEquivalent: "")
|
||||
item.state = LaunchAtLogin.isEnabled ? .on : .off
|
||||
}
|
||||
|
||||
private func buildShowWCAGItem() {
|
||||
let item = contextMenu.addItem(withTitle: "Show WCAG contrast level", action: #selector(setShowWCAG(_:)), keyEquivalent: "")
|
||||
item.state = PPState.shared.showWCAGLevel ? .on : .off
|
||||
}
|
||||
|
||||
@objc private func setShowWCAG(_ sender: NSMenuItem) {
|
||||
PPState.shared.showWCAGLevel = sender.state != .on
|
||||
}
|
||||
|
||||
@objc private func launchAtLogin(_ sender: NSMenuItem) {
|
||||
LaunchAtLogin.isEnabled = !LaunchAtLogin.isEnabled
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
|
||||
import MASShortcut
|
||||
import CleanroomLogger
|
||||
//import CleanroomLogger
|
||||
|
||||
@NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@@ -20,16 +20,16 @@ import CleanroomLogger
|
||||
|
||||
// Setup logging and load state.
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
let minimumSeverity: LogSeverity = PPState.shared.defaults.bool(forKey: "debugMode") ? .debug : .info
|
||||
var logConfigurations: [LogConfiguration] = [
|
||||
RotatingLogFileConfiguration(minimumSeverity: minimumSeverity, daysToKeep: 7, directoryPath: defaultLogPath().path)
|
||||
]
|
||||
|
||||
#if DEBUG
|
||||
logConfigurations.append(XcodeLogConfiguration(minimumSeverity: .debug))
|
||||
#endif
|
||||
|
||||
Log.enable(configuration: logConfigurations)
|
||||
// let minimumSeverity: LogSeverity = PPState.shared.defaults.bool(forKey: "debugMode") ? .debug : .info
|
||||
// var logConfigurations: [LogConfiguration] = [
|
||||
// RotatingLogFileConfiguration(minimumSeverity: minimumSeverity, daysToKeep: 7, directoryPath: defaultLogPath().path)
|
||||
// ]
|
||||
//
|
||||
// #if DEBUG
|
||||
// logConfigurations.append(XcodeLogConfiguration(minimumSeverity: .debug))
|
||||
// #endif
|
||||
//
|
||||
// Log.enable(configuration: logConfigurations)
|
||||
PPState.shared.loadFromDisk()
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ import CleanroomLogger
|
||||
// hardware events are suppressed after functions like CGWarpMouseCursorPosition are used.
|
||||
CGEventSource(stateID: CGEventSourceStateID.combinedSessionState)?.localEventsSuppressionInterval = 0.05
|
||||
|
||||
Log.info?.message("Sucessfully launched.")
|
||||
// Log.info?.message("Sucessfully launched.")
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Pixel Picker
|
||||
//
|
||||
|
||||
import CleanroomLogger
|
||||
//import CleanroomLogger
|
||||
|
||||
extension CGImage {
|
||||
// In order to get the color at a given pixel from a CGImage, we need to convert the CGImage's
|
||||
@@ -55,7 +55,7 @@ extension CGImage {
|
||||
|
||||
// Creating the context failed, so return a default color instead.
|
||||
// Hopefully, this should never happen.
|
||||
Log.error?.message("Failed to create CGContext!")
|
||||
// Log.error?.message("Failed to create CGContext!")
|
||||
return NSColor.black
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.4.0</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>17</string>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -6,6 +6,23 @@
|
||||
import SwiftyJSON
|
||||
|
||||
extension NSColor {
|
||||
var hslSaturationComponent: CGFloat {
|
||||
let maxValue = max(self.redComponent, self.greenComponent, self.blueComponent)
|
||||
let minValue = min(self.redComponent, self.greenComponent, self.blueComponent)
|
||||
let diff = maxValue - minValue
|
||||
|
||||
let saturation = (self.lightnessComponent > 0.5) ?
|
||||
diff / (2 - maxValue - minValue) : diff / (maxValue + minValue)
|
||||
guard !saturation.isNaN, (self.saturationComponent > 0.00001 || self.brightnessComponent > 9.9999) else {
|
||||
return 0
|
||||
}
|
||||
return saturation
|
||||
}
|
||||
var lightnessComponent: CGFloat {
|
||||
let maxValue = max(self.redComponent, self.greenComponent, self.blueComponent)
|
||||
let minValue = min(self.redComponent, self.greenComponent, self.blueComponent)
|
||||
return (maxValue + minValue) / 2
|
||||
}
|
||||
// Convert an NSColor instance to JSON in order to save it to disk.
|
||||
static func serialize(_ color: NSColor) -> JSON {
|
||||
let export = color.usingColorSpace(.deviceRGB)!
|
||||
@@ -50,4 +67,31 @@ extension NSColor {
|
||||
let L = 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2];
|
||||
return L > 0.197 ? NSColor.black : NSColor.white
|
||||
}
|
||||
|
||||
// Calculates the contrast ratio of this color and another one, according to the W3C "Web Content Accessibility Guidelines (WCAG) 2.0" Recommendation (https://www.w3.org/TR/WCAG20/).
|
||||
// Adopted from: https://gist.github.com/ngquerol/23d6d5ebd051e18682badafa37e48442
|
||||
public func contrastRatio(to color: NSColor) -> CGFloat {
|
||||
let luminance1 = relativeLuminance,
|
||||
luminance2 = color.relativeLuminance
|
||||
|
||||
if luminance1 < luminance2 {
|
||||
return (luminance2 + 0.05) / (luminance1 + 0.05)
|
||||
} else {
|
||||
return (luminance1 + 0.05) / (luminance2 + 0.05)
|
||||
}
|
||||
}
|
||||
|
||||
// Calculates the relative brightness of a color, according to the W3C "Web Content Accessibility Guidelines (WCAG) 2.0" Recommendation (https://www.w3.org/TR/WCAG20/).
|
||||
// Adopted from: https://gist.github.com/ngquerol/23d6d5ebd051e18682badafa37e48442
|
||||
public var relativeLuminance: CGFloat {
|
||||
let f = { (component: CGFloat) -> CGFloat in
|
||||
return component <= 0.03928 ? component / 12.92 : pow((component + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
|
||||
let red = f(redComponent)
|
||||
let green = f(greenComponent)
|
||||
let blue = f(blueComponent)
|
||||
|
||||
return red * 0.2126 + green * 0.7152 + blue * 0.0722
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Pixel Picker
|
||||
//
|
||||
|
||||
import CleanroomLogger
|
||||
//import CleanroomLogger
|
||||
|
||||
// This is the controller for the actual pixel picker itself.
|
||||
class PPOverlayController: NSWindowController {
|
||||
@@ -18,6 +18,8 @@ class PPOverlayController: NSWindowController {
|
||||
@IBOutlet weak var infoWrapper: NSView!
|
||||
@IBOutlet weak var infoFormatField: NSTextField!
|
||||
@IBOutlet weak var infoDetailField: NSTextField!
|
||||
@IBOutlet weak var infoContrastView: NSView!
|
||||
@IBOutlet weak var infoContrastField: NSTextField!
|
||||
|
||||
// This mode increases the picker's size, increases the magnification and also slows down move
|
||||
// events to make it easier to pick the right pixel. We dissociate the mouse (input) from the
|
||||
@@ -66,6 +68,8 @@ class PPOverlayController: NSWindowController {
|
||||
infoWrapper.wantsLayer = true
|
||||
infoWrapper.layer?.cornerRadius = 8
|
||||
infoWrapper.layer?.backgroundColor = NSColor.black.cgColor
|
||||
infoContrastView.wantsLayer = true
|
||||
infoContrastView.layer?.cornerRadius = 3
|
||||
|
||||
// For some reason if we don't listen for events this way we miss the escape key.
|
||||
NSEvent.addLocalMonitorForEvents(matching: [.keyDown]) {
|
||||
@@ -274,6 +278,21 @@ class PPOverlayController: NSWindowController {
|
||||
infoDetailField.textColor = contrastingColor
|
||||
infoFormatField.stringValue = PPState.shared.chosenFormat.rawValue
|
||||
infoDetailField.stringValue = PPState.shared.chosenFormat.asComponentString(withColor: color)
|
||||
|
||||
// Show contrast level if it's enabled and a color has previously been picked.
|
||||
if let previousPick = PPState.shared.recentPicks.last, PPState.shared.showWCAGLevel {
|
||||
infoContrastView.isHidden = false
|
||||
|
||||
// Calculate constrast ratio between current and previously picked color.
|
||||
let wcagLevel = WCAGLevel(contrastRatio: color.contrastRatio(to: previousPick.color))
|
||||
infoContrastField.stringValue = wcagLevel.rawValue
|
||||
|
||||
infoContrastView.layer?.backgroundColor = previousPick.color.cgColor
|
||||
infoContrastField.textColor = previousPick.color.bestContrastingColor()
|
||||
} else {
|
||||
infoContrastView.isHidden = true
|
||||
}
|
||||
|
||||
resizeInfoPanel()
|
||||
}
|
||||
|
||||
@@ -303,7 +322,7 @@ class PPOverlayController: NSWindowController {
|
||||
|
||||
// Calculate a zoomed rect which will crop the screenshot we took.
|
||||
let magnification = CGFloat(PPState.shared.magnificationLevel)
|
||||
let zoomReciprocal: CGFloat = 1.0 / (focusMode ? magnification * 2.5 : magnification)
|
||||
let zoomReciprocal: CGFloat = 1.0 / (focusMode ? magnification * 2.0 : magnification)
|
||||
let currentSize = CGFloat(screenShot.width) + 1
|
||||
let origin = floor(currentSize * ((1 - zoomReciprocal) / 2))
|
||||
let x = origin + (isHalf(normalisedPoint.x) ? 1 : 0)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14109"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -20,6 +19,8 @@
|
||||
</customObject>
|
||||
<customObject id="ECQ-9M-Pkg" customClass="PPOverlayController" customModule="PixelPicker" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="infoContrastField" destination="iRx-oZ-llC" id="gxr-6f-BkE"/>
|
||||
<outlet property="infoContrastView" destination="dIL-Oc-RkF" id="8ya-Ai-pt6"/>
|
||||
<outlet property="infoDetailField" destination="Re2-GH-fyd" id="K03-75-cf9"/>
|
||||
<outlet property="infoFormatField" destination="1fa-UE-yMM" id="Nan-fO-kbu"/>
|
||||
<outlet property="infoPanel" destination="OMO-LB-w57" id="GGj-Y6-LfU"/>
|
||||
@@ -30,11 +31,11 @@
|
||||
<outlet property="wrapper" destination="acW-WA-gq2" id="Mpu-0H-rtC"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="gZA-A3-IZ5" customClass="PPOverlayPanel" customModule="PixelPicker" customModuleProvider="target">
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="gZA-A3-IZ5" customClass="PPOverlayPanel" customModule="PixelPicker" customModuleProvider="target">
|
||||
<windowStyleMask key="styleMask" utility="YES" nonactivatingPanel="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="132" width="101" height="101"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
|
||||
<view key="contentView" id="acW-WA-gq2" customClass="PPOverlayWrapper" customModule="PixelPicker" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="101" height="101"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
@@ -52,38 +53,70 @@
|
||||
</view>
|
||||
<point key="canvasLocation" x="236" y="82"/>
|
||||
</window>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="OMO-LB-w57" customClass="PPOverlayPanel" customModule="PixelPicker" customModuleProvider="target">
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="OMO-LB-w57" customClass="PPOverlayPanel" customModule="PixelPicker" customModuleProvider="target">
|
||||
<windowStyleMask key="styleMask" utility="YES" nonactivatingPanel="YES"/>
|
||||
<rect key="contentRect" x="926" y="538" width="100" height="50"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
|
||||
<view key="contentView" id="HED-rR-FDP">
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
|
||||
<view key="contentView" misplaced="YES" id="HED-rR-FDP">
|
||||
<rect key="frame" x="0.0" y="0.0" width="100" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1fa-UE-yMM">
|
||||
<rect key="frame" x="-2" y="25" width="104" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="RkG-Wy-Shq">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Re2-GH-fyd">
|
||||
<rect key="frame" x="-2" y="8" width="104" height="14"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="IYd-1Y-7cd">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<stackView distribution="fill" orientation="vertical" alignment="centerX" spacing="4" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GvI-6B-Cz3">
|
||||
<rect key="frame" x="0.0" y="8" width="163" height="56"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1fa-UE-yMM">
|
||||
<rect key="frame" x="61" y="40" width="41" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="RkG-Wy-Shq">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Re2-GH-fyd">
|
||||
<rect key="frame" x="63" y="22" width="37" height="14"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="IYd-1Y-7cd">
|
||||
<font key="font" metaFont="label" size="11"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="dIL-Oc-RkF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="163" height="18"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iRx-oZ-llC">
|
||||
<rect key="frame" x="2" y="2" width="159" height="14"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="WGV-Vi-VsP">
|
||||
<font key="font" metaFont="label" size="11"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="iRx-oZ-llC" secondAttribute="trailing" constant="4" id="N7S-Bx-3p1"/>
|
||||
<constraint firstAttribute="bottom" secondItem="iRx-oZ-llC" secondAttribute="bottom" constant="2" id="cN6-Qx-Meg"/>
|
||||
<constraint firstItem="iRx-oZ-llC" firstAttribute="leading" secondItem="dIL-Oc-RkF" secondAttribute="leading" constant="4" id="pS4-Xb-76o"/>
|
||||
<constraint firstItem="iRx-oZ-llC" firstAttribute="top" secondItem="dIL-Oc-RkF" secondAttribute="top" constant="2" id="xNR-KQ-YT8"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
</subviews>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="1fa-UE-yMM" firstAttribute="leading" secondItem="HED-rR-FDP" secondAttribute="leading" id="23z-pW-nAx"/>
|
||||
<constraint firstItem="1fa-UE-yMM" firstAttribute="top" secondItem="HED-rR-FDP" secondAttribute="top" constant="8" id="G1j-j5-iWY"/>
|
||||
<constraint firstItem="Re2-GH-fyd" firstAttribute="leading" secondItem="HED-rR-FDP" secondAttribute="leading" id="aZf-QY-Lpd"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Re2-GH-fyd" secondAttribute="bottom" constant="8" id="amm-jV-oWa"/>
|
||||
<constraint firstAttribute="trailing" secondItem="1fa-UE-yMM" secondAttribute="trailing" id="flM-Te-2qj"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Re2-GH-fyd" secondAttribute="trailing" id="jWO-5f-uxW"/>
|
||||
<constraint firstItem="GvI-6B-Cz3" firstAttribute="leading" secondItem="HED-rR-FDP" secondAttribute="leading" id="3zK-14-Xf5"/>
|
||||
<constraint firstAttribute="bottom" secondItem="GvI-6B-Cz3" secondAttribute="bottom" constant="8" id="apf-V6-NGV"/>
|
||||
<constraint firstItem="GvI-6B-Cz3" firstAttribute="top" secondItem="HED-rR-FDP" secondAttribute="top" constant="8" id="dK9-Wq-zGV"/>
|
||||
<constraint firstAttribute="trailing" secondItem="GvI-6B-Cz3" secondAttribute="trailing" id="mj1-AT-sJL"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<point key="canvasLocation" x="236" y="230"/>
|
||||
|
||||
@@ -222,9 +222,9 @@ enum PPColor: String, CaseIterable {
|
||||
// Special formatter since CSS uses a unique style here, eg: "35, 79%, 47%".
|
||||
private func formatAsHSL(_ color: NSColor, _ template: String) -> String {
|
||||
let h = min(Int(color.hueComponent * 360), 359)
|
||||
let s = Int(color.saturationComponent * 100)
|
||||
let b = Int(color.brightnessComponent * 100)
|
||||
return String(format: template, h, s, b)
|
||||
let s = Int(color.hslSaturationComponent * 100)
|
||||
let l = Int(color.lightnessComponent * 100)
|
||||
return String(format: template, h, s, l)
|
||||
}
|
||||
|
||||
// Returns a new color in the correct colorspace for the format.
|
||||
|
||||
+18
-10
@@ -6,7 +6,7 @@
|
||||
import SwiftyJSON
|
||||
import MASShortcut
|
||||
import LaunchAtLogin
|
||||
import CleanroomLogger
|
||||
//import CleanroomLogger
|
||||
|
||||
// This state class is responsible for saving/loading application state and keeping
|
||||
// track of the active state and user configuration.
|
||||
@@ -29,6 +29,9 @@ import CleanroomLogger
|
||||
// Whether the color format should be uppercased or not.
|
||||
var useUppercase: Bool = false
|
||||
|
||||
// Whether to display the WCAG contrast level when picking a color.
|
||||
var showWCAGLevel: Bool = false
|
||||
|
||||
// The chosen icon for the status item (the icon in the menu bar).
|
||||
var statusItemImageName: String = "icon-default"
|
||||
|
||||
@@ -84,6 +87,7 @@ import CleanroomLogger
|
||||
func resetState() {
|
||||
paschaModeEnabled = false
|
||||
useUppercase = false
|
||||
showWCAGLevel = false
|
||||
statusItemImageName = "icon-default"
|
||||
focusModeModifier = .control
|
||||
activatingShortcut = nil
|
||||
@@ -101,10 +105,10 @@ import CleanroomLogger
|
||||
try loadFromString(jsonString)
|
||||
} catch {
|
||||
// Ignore error when there's no file.
|
||||
let err = error as NSError
|
||||
if err.domain != NSCocoaErrorDomain && err.code != CocoaError.fileReadNoSuchFile.rawValue {
|
||||
Log.error?.message("Unexpected error loading application state from disk: \(error)")
|
||||
}
|
||||
// let err = error as NSError
|
||||
// if err.domain != NSCocoaErrorDomain && err.code != CocoaError.fileReadNoSuchFile.rawValue {
|
||||
// Log.error?.message("Unexpected error loading application state from disk: \(error)")
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +122,8 @@ import CleanroomLogger
|
||||
paschaModeEnabled = value.bool ?? false
|
||||
case "useUppercase":
|
||||
useUppercase = value.bool ?? false
|
||||
case "showWCAGLevel":
|
||||
showWCAGLevel = value.bool ?? false
|
||||
case "statusItemImageName":
|
||||
statusItemImageName = value.string ?? "icon-default"
|
||||
case "focusModeModifier":
|
||||
@@ -145,11 +151,12 @@ import CleanroomLogger
|
||||
case "recentPicks":
|
||||
recentPicks = deserializeRecentPicks(fromJSON: value)
|
||||
default:
|
||||
Log.warning?.message("unknown key '\(key)' encountered in json")
|
||||
continue
|
||||
// Log.warning?.message("unknown key '\(key)' encountered in json")
|
||||
}
|
||||
}
|
||||
|
||||
Log.info?.message("Loaded config from disk")
|
||||
// Log.info?.message("Loaded config from disk")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +182,7 @@ import CleanroomLogger
|
||||
let json: JSON = [
|
||||
"paschaModeEnabled": paschaModeEnabled,
|
||||
"useUppercase": useUppercase,
|
||||
"showWCAGLevel": showWCAGLevel,
|
||||
"statusItemImageName": statusItemImageName,
|
||||
"focusModeModifier": focusModeModifier.rawValue,
|
||||
"activatingShortcut": shortcutData,
|
||||
@@ -189,12 +197,12 @@ import CleanroomLogger
|
||||
let configDir = savePath.deletingLastPathComponent()
|
||||
try FileManager.default.createDirectory(atPath: configDir.path, withIntermediateDirectories: true, attributes: nil)
|
||||
try jsonString.write(to: savePath, atomically: false, encoding: .utf8)
|
||||
Log.info?.message("Saved config to disk")
|
||||
// Log.info?.message("Saved config to disk")
|
||||
} else {
|
||||
Log.error?.message("Could not serialise config")
|
||||
// Log.error?.message("Could not serialise config")
|
||||
}
|
||||
} catch {
|
||||
Log.error?.message("Unexpected error saving application state to disk: \(error)")
|
||||
// Log.error?.message("Unexpected error saving application state to disk: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Pixel Picker
|
||||
//
|
||||
|
||||
import CleanroomLogger
|
||||
//import CleanroomLogger
|
||||
|
||||
let APP_NAME = Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String
|
||||
let APPLE_INTERFACE_STYLE = "AppleInterfaceStyle"
|
||||
@@ -82,10 +82,10 @@ func defaultLogPath() -> URL {
|
||||
do {
|
||||
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true, attributes: nil)
|
||||
} catch {
|
||||
Log.error?.message("Unexpected error creating log directory: \(error)")
|
||||
// Log.error?.message("Unexpected error creating log directory: \(error)")
|
||||
}
|
||||
|
||||
Log.info?.message("Default Log Path: \(url.path)")
|
||||
// Log.info?.message("Default Log Path: \(url.path)")
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -98,6 +98,6 @@ func defaultConfigurationPath() -> URL {
|
||||
url = URL(fileURLWithPath: "\(NSHomeDirectory())/Library/Preferences/\(APP_NAME)/configuration.json")
|
||||
}
|
||||
|
||||
Log.info?.message("Default Config Path: \(url.path)")
|
||||
// Log.info?.message("Default Config Path: \(url.path)")
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// WCAG.swift
|
||||
// Pixel Picker
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// Represents the different WCAG contrast levels defined by: https://www.w3.org/TR/WCAG20/.
|
||||
enum WCAGLevel: String {
|
||||
case AAA
|
||||
case AA
|
||||
case OK
|
||||
case Fail
|
||||
|
||||
// The contrast intervals are based on the minimums for regular text in https://www.w3.org/TR/WCAG20/.
|
||||
init(contrastRatio: CGFloat) {
|
||||
switch contrastRatio {
|
||||
case _ where contrastRatio >= 7:
|
||||
self = .AAA
|
||||
case _ where contrastRatio >= 4.5:
|
||||
self = .AA
|
||||
case _ where contrastRatio >= 3:
|
||||
self = .OK
|
||||
default:
|
||||
self = .Fail
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ Pixel Picker is like Digital Color Meter, but lives in your menu bar and lets yo
|
||||
* 🎨 Supports different color spaces
|
||||
* ⌨️ Global keyboard shortcut activation
|
||||
* 🌄 Customisable preview
|
||||
* 🌓 WCAG contrast level checker
|
||||
* ✨
|
||||
|
||||

|
||||
@@ -63,6 +64,8 @@ Pixel Picker provides some neat options:
|
||||
* The global keyboard shortcut to use that will activate Pixel Picker.
|
||||
* 🚀 **Launch at Login**
|
||||
* If this is enabled then Pixel Picker will be launched when you log into your computer.
|
||||
* 🌓 **WCAG Constrast Level**
|
||||
* If enabled, will compare the current and last picked color and show the [WCAG constrast level](https://www.w3.org/TR/WCAG20/): Fail, OK, AA, or AAA.
|
||||
|
||||
#### Extra Overrides or Hidden Settings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user