A cross-platform window focus tracker that records how much time you spend on each application. Built in Rust for performance and portability.
- Cross-platform: Supports Linux (Sway/X11), macOS, and Windows.
- Lightweight: Minimal dependencies, no GUI, and low resource usage.
- Persistent: Saves window focus durations to
~/.local/share/window-time-tracker/durations.tsv. - Real-time: Logs focus changes as they happen.
- Ensure Rust is installed (
rustcandcargo). - Clone this repository:
git clone https://github.com/your-username/winsight.git cd winsight - Build and run:
cargo run --release
If using Nix, a flake.nix is provided for development:
nix develop
cargo runRun the binary to start tracking:
cargo run- Focus changes are logged to stdout (e.g.,
-> firefox). - Data is saved to
~/.local/share/window-time-tracker/durations.tsvin the format:<window_name> <duration_seconds>
- Linux: Auto-detects between Sway (Wayland) and X11 backends.
- macOS: Uses native Objective-C APIs.
- Windows: Uses Win32 APIs.
To enable a specific backend, uncomment the relevant dependencies in Cargo.toml:
[target.'cfg(target_os = "linux")'.dependencies]
swayipc = "3" # For Sway (Wayland)
x11rb = "0.13" # For X11- Location:
~/.local/share/window-time-tracker/durations.tsv - Format: Tab-separated values (window name → total seconds).
- Example:
firefox 3600 vscode 7200
src/
backend/
linux.rs # Linux-specific backend (Sway/X11)
macos.rs # macOS backend
mod.rs # Backend trait and detection logic
windows.rs # Windows backend
main.rs # Core logic (event handling, storage)
- Implement the
FocusBackendtrait in a new module (e.g.,src/backend/wayland.rs). - Update
detect_backend()inmod.rsto include the new backend. - Add dependencies to
Cargo.tomlunder the appropriatetarget_ossection.
MIT OR Apache-2.0 (dual-licensed, same as Rust).