WatchEye

1.1

A simple Swift library for watching over your macOS activity
m1guelpf/WatchEye

What's New

Add BrowserUtils

2025-01-26T01:06:41Z

Full Changelog: v1.0...v1.1

A simple Swift library for watching over your macOS activity

Install Size Swift Version GitHub license

This library sits on top of the macOS Accessibility API, making it easy to react when the user changes the active application, or when the window the user is focused on changes its title. It also includes some basic utilities for working with browsers.

Installation

Swift Package Manager

The Swift Package Manager allows for developers to easily integrate packages into their Xcode projects and packages; and is also fully integrated into the swift compiler.

SPM Through XCode Project

SPM Through Xcode Package

Once you have your Swift package set up, add the Git link within the dependencies value of your Package.swift file.

dependencies: [
    .package(url: "https://github.com/m1guelpf/WatchEye.git", .branch("main"))
]

Getting started 🚀

The easiest way to get started is to define a delegate and start reacting to events:

import AppKit
import WatchEye
import Foundation

class ExampleWatchEyeDelegate {
	let watchEye: WatchEye

	init() {
		watchEye = WatchEye()
		watchEye.delegate = self
	}
}

extension ExampleWatchEyeDelegate: WatchEyeDelegate {
	func watchEyeDidReceiveAccessibilityPermissions(_: WatchEye) {
        print("Accessibility permissions granted!")
    }

	func watchEye(_: WatchEye, didFocusApplication app: NSRunningApplication) {
        print("\(app.bundleIdentifier!) is now in focus")
    }

	func watchEye(_: WatchEye, didChangeTitleOf app: NSRunningApplication, newTitle title: String) {
        if app.browser?.isIncognito(windowTitle: title) == true { return }

		print("Title of \(app.bundleIdentifier!) changed to \(title)")

        if let url = app.browser?.getURL() {
			print("URL of \(app.bundleIdentifier!) is now \(url)")
		}
	}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

Last updated: Fri May 16 2025 06:33:43 GMT-0900 (Hawaii-Aleutian Daylight Time)