#monitor #input-event #events #window #focus #tracking #level

bin+lib os-monitor

OS level monitor for tracking window focus and input events

12 releases

new 0.3.1 Feb 19, 2025
0.3.0 Feb 19, 2025
0.2.3 Feb 17, 2025
0.1.5 Feb 6, 2025
0.1.3 Jan 30, 2025

#285 in Hardware support

Download history 377/week @ 2025-01-29 515/week @ 2025-02-05 53/week @ 2025-02-12

945 downloads per month
Used in os-monitor-service

MIT license

47KB
1K SLoC

Rust 617 SLoC // 0.0% comments Objective-C 254 SLoC // 0.1% comments C 166 SLoC // 0.1% comments

Monitor

The monitor is a Rust application that runs on your computer and is responsible for monitoring your activities. It is specifically responsible for monitoring (but not recording) your window, mouse and keyboard activity. Architecture supports multiple platforms.

Implemented platforms:

  • macOS
  • Windows
  • Linux

Example Usage

Here's an example of how to use the monitor as a library by registering event callbacks:

   let monitor = Monitor::new();

   // Register event callbacks
   monitor.register_keyboard_callback(Box::new(on_keyboard_events));
   monitor.register_mouse_callback(Box::new(on_mouse_events));
   monitor.register_window_callback(Box::new(on_window_event));

   initialize_monitor(Arc::new(monitor)).expect("Failed to initialize monitor");
   loop {
      detect_changes().expect("Failed to detect changes");
      std::thread::sleep(std::time::Duration::from_secs(1));
   }

On first run on macOS, you'll need to grant accessibility permissions to the application. This is required to monitor window focus and input events.

Building and Running

cargo build
cargo run

Prerequisites

  • Rust toolchain (install via rustup)
  • For macOS:
    • Xcode Command Line Tools

Architecture

See architecture.md for more information.

Security and Privacy

  • The monitor only tracks event metadata, not content
  • Window titles, application names, and browser urls are captured for context
  • All data processing happens locally

Development Guidelines

Adding OS Support

To add support for a new OS platform:

  1. Create new platform-specific module in src/platform/
  2. Implement native bindings in bindings/
  3. Implement required traits and functions
  4. Update conditional compilation flags

Other notes

Brought over from the original repo: https://github.com/CodeClimbersIO/app-codeclimbers

Dependencies

~2–9.5MB
~99K SLoC