HyprSpy is a lightweight Python utility for tracking your active window usage on Hyprland-based Linux systems. It periodically records the currently focused window's class and title, along with timestamps, to a local SQLite database. This allows you to analyze your workflow, productivity, or simply keep a history of your window activity.
- Monitors the active window every second
- Logs window class and title with start time and duration
- Stores data in a local SQLite database (
logs.db) - Sends a notification after a configurable number of minutes (
notify_minutes) of continuous usage of the same application (with--usage) - Simple, efficient, and easy to use
- Python 3.7 or newer
- Hyprland window manager
hyprctlcommand-line tool (included with Hyprland)- Standard Python libraries:
sqlite3,subprocess,json,time,os,sys,atexit
-
Clone the repository:
git clone https://github.com/Biri0/hyprspy.git cd hyprspy -
Make sure you are running Hyprland and have
hyprctlavailable in your PATH.
The best way to start HyprSpy is to add the following line to your hyprland.conf file:
exec-once = python3 /absolute/path/to/hyprspy/main.py
Replace /absolute/path/to/hyprspy/main.py with the actual path to the file on your system. This will ensure HyprSpy starts automatically when your Hyprland session begins.
You can also run the script manually:
python3 main.pyThis will start logging your active window information to logs.db located in the same directory as the script, regardless of where you run the command. The script runs indefinitely, updating the database every second.
HyprSpy creates a SQLite database named logs.db with a single table:
logs(start_time, seconds, class, title)
Each entry represents a period during which a specific window was active. start_time is a timestamp in milliseconds, seconds is the duration in seconds, while class and title describe the window.
To view your logged window activity, you can use the SQLite CLI:
sqlite3 logs.db "SELECT * FROM logs ORDER BY start_time DESC LIMIT 10;"This project is licensed under the MIT License.
Feel free to contribute or suggest improvements!