繁体   English   中英

隐藏在 macOS 13 Ventura 上登录时启动的应用程序

[英]Hide app that was launched on login on macOS 13 Ventura

直到 macOS 12,用户和组系统偏好设置中的每个登录项都有一个标记为“隐藏”的复选框。 现在在 macOS 13 中,登录项已移至常规系统偏好设置,但“隐藏”复选框已消失。 有没有一种方法可以从应用程序内部知道它是作为登录项启动的,而不提供应用程序内的“登录时启动”选项,这将使我能够控制整个过程,但要更换它会相当费力那一个小选项?

我最终决定假设如果一个应用程序在登录项中,它应该始终隐藏启动。 如果用户手动启动它(从 Dock、Finder 或 Launchpad),那么它在默认情况下仍处于隐藏状态,但这种情况可能不会经常发生)。 在 Apple 提供一种检查应用程序是否已在登录时自动启动的方法之前,我不想花时间弄清楚做这些简单事情的方法。

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)
        }
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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