View on GitHub

cat-window-watcher

cat-window-watcher

cat-window-watcher - Cat is watching you -

A simple, standalone window monitoring tool that watches your active window and adjusts your score based on your activity.

Japanese English

WIP

Currently under development. There are bugs. Please refer to issues.

⚠️ Note on Temporary Implementation

This is a temporary implementation for testing and validation purposes. The current implementation focuses on:

Future versions may include optimizations and integrations, but this version prioritizes simplicity and ease of understanding.

Concept

The application monitors your currently active window and adjusts a score based on configurable patterns:

The cat is watching you!

Features

About Screensaver Detection

This application detects if a screensaver is active and prevents score changes during its operation.

Detection Method: If the window title is an empty string, it is treated as a screensaver.

This practical and simple approach provides higher reliability compared to complex platform-specific implementations. However, please note that special applications without a window title might also be treated as a screensaver.

Appearance

╔════════════════════════════════════════════════════════════╗
β•‘   Cat Window Watcher - Cat is watching you -               β•‘
╠════════════════════════════════════════════════════════════╣
β•‘                                                            β•‘
β•‘                                                            β•‘
β•‘                       Score: 42                            β•‘
β•‘                                                            β•‘
β•‘                                                            β•‘
β•‘                      GitHub (+10)                          β•‘
β•‘                                                            β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

The GUI features a dark theme with a large score display and a status indicating the current activity.

Installation

  1. Clone the repository:
    git clone https://github.com/cat2151/cat-window-watcher.git
    cd cat-window-watcher
    
  2. Ensure Python 3.12 or higher is installed:
    python --version
    
  3. Install dependencies (if necessary):
    • Linux: xdotool or xprop (usually pre-installed)
    • macOS: Built-in AppleScript support
    • Windows: Works with built-in API (optionally pywin32 for better support)

Configuration

  1. Copy the example configuration:
    cp config.toml.example config.toml
    
  2. Edit config.toml to customize window patterns and scores:
# Default score (applied when no pattern matches)
# Used to easily detect misconfigurations
# -1 (default) for easy detection, 0 to disable
default_score = -1

[[window_patterns]]
description = "GitHub"
regex = "github"
score = 10

[[window_patterns]]
description = "Twitter/X"
regex = "twitter|x\\.com"
score = -5

Configuration Options

Global Configuration Options

The following options are written at the top level of config.toml (outside of [[window_patterns]]):

Window Pattern Specific Options

The following options are written within a [[window_patterns]] section:

Usage

Run the application:

# Method 1: Run the script directly
python src/main.py

# Method 2: Run as a module
python -m src

# Method 3: Run with a custom config file
python src/main.py --config my_config.toml
python src/main.py -c my_config.toml

The GUI will display:

Examples

For more detailed configuration examples, please refer to the examples/ directory.

Example 1: Productivity Tracking

See examples/example1_productivity.ja.toml

[[window_patterns]]
description = "Coding"
regex = "github|gitlab"
score = 10

[[window_patterns]]
description = "Social Media"
regex = "twitter|facebook|instagram"
score = -5

Example 2: Study Time

See examples/example2_study_time.ja.toml

[[window_patterns]]
description = "Reading"
regex = "pdf|documentation|docs"
score = 8

[[window_patterns]]
description = "Entertainment"
regex = "youtube|netflix"
score = -10

Example 3: Always on Top Mode with Auto-Hide on Mouse Proximity

See examples/example3_always_on_top.ja.toml

# Keep the window always on top, but automatically move it to the bottom when the mouse is near
always_on_top = true
hide_on_mouse_proximity = true
proximity_distance = 50

[[window_patterns]]
description = "GitHub"
regex = "github"
score = 10

With this configuration, the window will generally stay on top, but when the mouse cursor approaches within 50 pixels, it will automatically move to the bottom, returning to the top when the mouse moves away. This is designed to not interfere with your work.

Development

Running Tests

python -m unittest discover tests/ -v

Code Formatting

Format code before committing:

ruff format src/ tests/
ruff check --fix src/ tests/

Linting

Validate code quality:

ruff format --check src/ tests/
ruff check src/ tests/

Architecture

The application is composed of several modules:

Platform-Specific Notes

Linux

Requires xdotool or xprop:

sudo apt-get install xdotool  # Debian/Ubuntu

macOS

Uses built-in AppleScript. No additional dependencies required.

Windows

Works with built-in Windows API. For better compatibility, install:

pip install pywin32

License

See the LICENSE file for details.

Big Brother is watching you. But this time, it’s a cat. 🐱