简体   繁体   中英

Hide app that was launched on login on macOS 13 Ventura

Up until macOS 12, there was a checkbox labelled "Hide" for each login item in the Users & Groups System Preferences. Now in macOS 13 the login items have been moved to the General System Preferences, but the "Hide" checkbox has disappeared. Is there a way to know from within the app that it was launched as a login item, without offering an in-app "Launch at login" option which would allow me to control the whole process, but would be quite some effort to just replace that one little option?

I eventually decided to assume that if an app is among the login items, it should always be launched hidden. If the user launches it manually (from the Dock, Finder or Launchpad) then it is still hidden by default, but this scenario probably doesn't happen too often). Until Apple provides a way of checking if an app has been launched automatically at login, I don't want to spend time figuring out ways of doing such simple things.

class AppDelegate: NSObject, NSApplicationDelegate {
    
    func applicationWillFinishLaunching(_ aNotification: Notification) {
        let window = (NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "MainWindowController") as! NSWindowController).window!
        if #available(macOS 13.0, *) {
            if SMAppService.mainApp.status != .enabled {
                window.makeKeyAndOrderFront(nil)
            }
        } else {
            window.makeKeyAndOrderFront(nil)
        }
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM