diff --git a/Sources/LaunchAtLogin/LaunchAtLogin.swift b/Sources/LaunchAtLogin/LaunchAtLogin.swift index e35b2bd..d558f58 100644 --- a/Sources/LaunchAtLogin/LaunchAtLogin.swift +++ b/Sources/LaunchAtLogin/LaunchAtLogin.swift @@ -30,6 +30,17 @@ public enum LaunchAtLogin { } } } + + /** + Whether the app was launched at login. + + - Important: This property must only be checked in `NSApplicationDelegate#applicationDidFinishLaunching`. + */ + public static var wasLaunchedAtLogin: Bool { + let event = NSAppleEventManager.shared().currentAppleEvent + return event?.eventID == kAEOpenApplication + && event?.paramDescriptor(forKeyword: keyAEPropData)?.enumCodeValue == keyAELaunchedAsLogInItem + } } extension LaunchAtLogin { diff --git a/readme.md b/readme.md index b97f816..79beb71 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# LaunchAtLogin *(Modern)* +# LaunchAtLogin > Add “Launch at Login” functionality to your macOS app in seconds