Skip to content

curzel-it/WindowsDetector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WindowsDetector

Swift Package to list all windows running on the user macOS system.

This solution is App Store-compliant and does not require user actions, nor special permissions.

This is being used in production by my Desktop Pets app (which is also here on GitHub).

The package will return a mocked, empty, list of windows on iOS, support has been added to ease development of multiplatform apps.

Usage

You can use a WindowsDetector instance like any other ObservableObject, like in the state of your view:

import SwiftUI
import WindowsDetector

struct WindowsListView: View {
    
    @StateObject var windowsDetector = WindowsDetector().started(pollInterval: 1)
    
    var body: some View {
        List(windowsDetector.userWindows) { window in
            Text(window.description)
                .background(window.isFrontmost ? Color.red : Color.clear)
        }
    }
}

Or, you can use the underlying service as you need:

import WindowsDetector

let service = WindowsDetectionService()
let windows = service.listCurrentWindows()

About

Provides a list of all windows running on the user macOS system

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages