You are asking about building an Apple application. Probably off-topic for these forums since it's not about Swift (you could write the entire application in Objective-C, for example). You might try StackOverflow or the Apple Developer forums, for assistance.
activate. on global: I am not sure about the exact mechanism. I tried looking in Karabiner-elements but didn't know what I was looking for. Similar to the startup items, it has something to do with accessibility and control of the computer. (It's the reason that Alfred is in the Accessibility section on security)
Since my app is already "an agent" in order to just show up in menubar, from your suggestions it should just be added to "Login items" and it will work? Great if that is all it takes, but how to do that through an option within the app?
@sindresorhus I'm not sure how to use your package and if everything works when the app is an agent then there is no need for it, right?
This is very Mac specific stuff, and so I’m reluctant to chime in here on Swift Forums. If you want to start a thread over on DevForums, and specifically in the Core OS > Processes topic area, I’d be happy to help out there.