I want to build a simple service that will allow me to keep any app window always on top or always on the same screen, when switching desktops.
Is there a way to build a global MacOS service-only application (without any windows etc.) and how is the preferred way to do this? (Automator, AppKit, SwiftUI).
The app should also be distributable via AppStore (or if not possible just GitHub).
Best Answer
You could build such a service using any tool that results in an application bundle; this includes AppleScript/JavaScript (OSA), Objective-C, and Swift. Apple would likely prefer you used Swift.
Investigate the Accessibility APIs for interacting and manipulating windows owned by other applications.
See the
Info.plist
value LSUIElement for making an agent application:To be distributed on Apple's Mac App Store, an application must have a user interface. This can be a simple window that enables your service, or handles preferences.
Search GitHub for status menu app for open source examples.