{"id":31580571,"url":"https://github.com/anto18671/mouse-entropy","last_synced_at":"2026-05-08T14:15:35.384Z","repository":{"id":282737151,"uuid":"946922694","full_name":"anto18671/mouse-entropy","owner":"anto18671","description":"Mouse Entropy is a CLI tool for capturing and storing raw mouse movement data on Arch-based Linux systems.","archived":false,"fork":false,"pushed_at":"2025-03-12T01:33:52.000Z","size":14384,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-17T11:00:05.729Z","etag":null,"topics":["archlinux","aur","cli","linux","mouse-tracking"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anto18671.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-11T22:16:00.000Z","updated_at":"2025-03-12T01:37:55.000Z","dependencies_parsed_at":"2025-03-17T04:16:23.004Z","dependency_job_id":null,"html_url":"https://github.com/anto18671/mouse-entropy","commit_stats":null,"previous_names":["anto18671/mouse-entropy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/anto18671/mouse-entropy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anto18671%2Fmouse-entropy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anto18671%2Fmouse-entropy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anto18671%2Fmouse-entropy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anto18671%2Fmouse-entropy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anto18671","download_url":"https://codeload.github.com/anto18671/mouse-entropy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anto18671%2Fmouse-entropy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32783712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archlinux","aur","cli","linux","mouse-tracking"],"created_at":"2025-10-05T21:15:08.386Z","updated_at":"2026-05-08T14:15:35.374Z","avatar_url":"https://github.com/anto18671.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mouse Entropy\n\n[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](#)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](#)\n\n---\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n  - [Building From Source](#building-from-source)\n  - [Arch Linux Package Installation](#arch-linux-package-installation)\n- [Configuration](#configuration)\n  - [TOML Configuration File](#toml-configuration-file)\n  - [Permissions](#permissions)\n- [Usage](#usage)\n  - [Commands](#commands)\n    - [Screenshot of the Help Command](#screenshot-of-the-help-command)\n    - [Explanation of Each Command](#explanation-of-each-command)\n  - [Daemon / Systemd Service](#daemon--systemd-service)\n- [Data Storage Structure](#data-storage-structure)\n- [Examples](#examples)\n  - [Quick Dump Example](#quick-dump-example)\n  - [Clearing Data](#clearing-data)\n  - [Viewing File Sizes](#viewing-file-sizes)\n- [Logging \u0026 Debugging](#logging--debugging)\n- [FAQ](#faq)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n- [Author / Maintainer](#author--maintainer)\n- [Acknowledgments](#acknowledgments)\n\n---\n\n## Introduction\n\n**Mouse Entropy** is a command-line tool designed primarily for Arch-based Linux systems to capture and store raw mouse event data. It can be useful for various purposes, such as:\n\n1. Generating entropy from user mouse movements.\n2. Analyzing mouse usage patterns.\n3. Collecting mouse input for testing or further research on human-computer interaction.\n\nThe tool reads events from the Linux mouse input device (`/dev/input/mice` by default) in real time and saves them to binary files. Data can then be easily dumped to CSV format for offline analysis.\n\n---\n\n## Features\n\n- **Real-time capturing** of mouse data from `/dev/input/mice`.\n- **Configurable storage** (directory structure, permissions, file sizes).\n- **Easy-to-use CLI** with subcommands for starting, stopping, clearing, dumping, and summarizing data sizes.\n- **Automatic file rotation** after configurable max file size is reached, preventing single large files.\n- **Daily folder structure** for easy organization, e.g. `data/YYYY/MM/DD`.\n- **CSV export** for offline analysis.\n- **Arch Linux systemd service** for hands-off, daemonized operation.\n\n---\n\n## Requirements\n\n- **Rust** (if building from source)\n- **Cargo** (if building from source)\n- **Arch Linux** or an Arch-based distribution (for the provided `.service` file and PKGBUILD usage).\n- **Privileges**: You typically need to run as `root` or be a member of the `input` group to access `/dev/input/mice`.\n\n---\n\n## Installation\n\n### Building From Source\n\n1. Clone this repository:\n\n   ```bash\n   git clone https://github.com/anto18671/mouse-entropy.git\n   ```\n\n2. Navigate to the project folder:\n\n   ```bash\n   cd mouse-entropy\n   ```\n\n3. Build in release mode:\n\n   ```bash\n   cargo build --release\n   ```\n\n4. Optionally, install it system-wide:\n\n   ```bash\n   sudo install -Dm755 target/release/mouse-entropy /usr/bin/mouse-entropy\n   ```\n\n5. Copy or move the default config file:\n\n   ```bash\n   sudo mkdir -p /etc/mouse-entropy\n   sudo cp mouse-entropy.toml /etc/mouse-entropy/\n   ```\n\n### Arch Linux Package Installation\n\nA `PKGBUILD` file is provided for Arch-based systems. You can build and install it using your favorite AUR helper or with the standard `makepkg` workflow.\n\n1. Download (or clone) the PKGBUILD and related files (`mouse-entropy.install`, `.service`, `.toml`, etc.).\n2. Run:\n\n   ```bash\n   makepkg -si\n   ```\n\n   This command will:\n\n   - Build the package.\n   - Prompt to install it (`-i`).\n   - Place the binary into `/usr/bin/mouse-entropy`.\n   - Place the default config into `/etc/mouse-entropy/mouse-entropy.toml`.\n   - Place the systemd service into `/usr/lib/systemd/system/mouse-entropy.service`.\n\nOnce installed, you have a fully functional `mouse-entropy` command-line tool.\n\n---\n\n## Configuration\n\nThe default configuration file is stored in:\n\n```\n/etc/mouse-entropy/mouse-entropy.toml\n```\n\n### TOML Configuration File\n\nBelow is an example TOML file with annotations:\n\n```toml\n[storage]\nbase_directory = \"data\"             # Directory where recorded data is stored\ndirectory_permissions = 448         # Decimal equivalent of 0o700 =\u003e drwx------\nfile_permissions = 384              # Decimal equivalent of 0o600 =\u003e -rw-------\nmax_file_size_mb = 2                # Maximum size of each data chunk file\nstore_4_bytes = false               # If true =\u003e store 4 bytes per event ([button, dx, dy, 0])\ndevice_path = \"/dev/input/mice\"     # Path to the mouse device file\n```\n\n**Key Points:**\n\n- `base_directory`: Where all data is stored. Can be absolute or relative.\n- `directory_permissions`: The directory permissions in decimal format. `448` = `0o700`.\n- `file_permissions`: The file permissions in decimal format. `384` = `0o600`.\n- `max_file_size_mb`: Once a data file hits this size, a new file is created.\n- `store_4_bytes`: Whether to store 3 or 4 bytes per event. The 4th byte is a zero-byte placeholder.\n- `device_path`: The input device. On many Linux systems, `/dev/input/mice` is used for aggregated mouse movements.\n\n### Permissions\n\n- If using the default `device_path = \"/dev/input/mice\"`, you need read access to this special file.\n  - Typically, you must run `mouse-entropy` as `root` or be in the `input` group.\n- The stored data and directories are created with the specified permissions (e.g., `0o700` for directories and `0o600` for files by default).\n\n---\n\n## Usage\n\n`mouse-entropy` is a command-line tool with multiple subcommands. Once installed, you can type `mouse-entropy --help` or just run it to see usage instructions.\n\n### Commands\n\nBelow is a screenshot of the help command output, followed by a detailed explanation for each subcommand.\n\n#### Screenshot of the Help Command\n\n![Help Command Screenshot](assets/screenshot.png)\n\n```\n$ mouse-entropy --help\n```\n\n```\nUsage: mouse-entropy \u003cCOMMAND\u003e\n\nCommands:\n  start    Start capturing mouse data in the foreground\n  stop     Stop capturing (stub; real implementation depends on daemonization)\n  clear    Clear all recorded data\n  dump     Dump data as CSV (optionally for one specific YYYY-MM-DD)\n  size     Summarize the size of all recorded data\n  help     Print this message or the help of the given subcommand(s)\n```\n\n_(Imagine a screenshot image here in your final README, showing the same content. Replace this code block with an actual screenshot or keep it as text if you prefer.)_\n\n#### Explanation of Each Command\n\n1. **start**\n\n   - Launches real-time capturing of mouse events from the configured `device_path`.\n   - Stores the binary event data into daily subfolders, splitting files when they exceed `max_file_size_mb`.\n   - Output continues until you interrupt (Ctrl + C) or otherwise kill the process.\n\n2. **stop**\n\n   - A stub subcommand. In future or alternative daemonized approaches, this could stop a running service or kill a process by PID file. Currently, use Ctrl + C or systemd to stop.\n\n3. **clear**\n\n   - Removes **all** recorded data in the configured `base_directory`.\n   - **Warning:** This is irreversible.\n\n4. **dump**\n\n   - Converts stored binary data to CSV output, either to `stdout` or a specified file.\n   - Optionally specify a date (`YYYY-MM-DD`) to only dump a single day's data.\n     - Example: `mouse-entropy dump --date 2025-01-01 --output data_2025_01_01.csv`\n   - If no date is specified, **all** days in `base_directory` are read and dumped.\n\n5. **size**\n   - Recursively walks the storage directories to calculate total usage by day, month, and year.\n   - Shows a summary of how large your stored data has become.\n\n---\n\n### Daemon / Systemd Service\n\nRunning `mouse-entropy start` manually will keep it in the foreground. For a persistent service, especially on an Arch-based system, you can use the included systemd unit file:\n\n1. **Enable** and **start** the service:\n\n   ```bash\n   sudo systemctl enable mouse-entropy.service\n   sudo systemctl start mouse-entropy.service\n   ```\n\n2. **Check logs**:\n\n   ```bash\n   journalctl -u mouse-entropy.service\n   ```\n\n3. **Stop** the service:\n\n   ```bash\n   sudo systemctl stop mouse-entropy.service\n   ```\n\nWith systemd managing the process, it will automatically restart on reboots and run in the background.\n\n---\n\n## Data Storage Structure\n\nWhen `mouse-entropy start` is running, it creates subdirectories under `base_directory` following this pattern:\n\n```\nbase_directory/\n└── YYYY\n    └── MM\n        └── DD\n            ├── YYYY-MM-DD-00001.bin\n            ├── YYYY-MM-DD-00002.bin\n            └── ...\n```\n\nFor each day, each chunk file is named:\n\n```\nYYYY-MM-DD-xxxxx.bin\n```\n\nWhere `xxxxx` is a 5-digit zero-padded index (e.g., `00001`).\n\nEach `.bin` file contains a raw sequence of 3 or 4 bytes per mouse event. The first byte is the button flags, and the second and third bytes are the signed `dx, dy` (movements). If `store_4_bytes` is `true`, a zero-padding byte is added as the fourth byte.\n\n---\n\n## Examples\n\n### Quick Dump Example\n\nLet's say you have been capturing data for a while and now want to convert a single day's data to CSV.\n\n```bash\nmouse-entropy dump --date 2025-01-01 --output january_1_data.csv\n```\n\nThe resulting CSV file `january_1_data.csv` might look like this:\n\n```csv\nbutton,dx,dy\n8,1,-1\n8,1,0\n8,1,2\n8,1,1\n...\n```\n\n- `button`: The raw button byte.\n- `dx` and `dy`: Movement deltas (signed 8-bit integers).\n\n### Clearing Data\n\nTo remove **all** collected data:\n\n```bash\nmouse-entropy clear\n```\n\nBy default, it removes whatever is in `base_directory` (as configured by your TOML file). **Use with caution.**\n\n### Viewing File Sizes\n\nIf you’d like to see how much data has been collected so far:\n\n```bash\nmouse-entropy size\n```\n\nExample output might be:\n\n```\nYear 2025 Month 01 Day 01 =\u003e 12345 bytes\nYear 2025 Month 01 Day 02 =\u003e 45678 bytes\nYear 2025 Month 01 =\u003e 58023 bytes\nYear 2025 =\u003e 58023 bytes\nTotal across all years/months/days =\u003e 58023 bytes\n```\n\n---\n\n## Logging \u0026 Debugging\n\nThis tool doesn’t provide extensive logging by default. However, if you run it in the foreground (i.e., `mouse-entropy start` directly), you can see:\n\n- Basic console messages (starting, capturing, file rotation).\n- Error messages if the device can’t be opened or read.\n\nFor systemd logging, use `journalctl -u mouse-entropy.service`.\n\n---\n\n## FAQ\n\n1. **Why do I need root privileges to capture mouse events?**  \n   By default, most Linux systems restrict read access to `/dev/input/mice`. You can change group permissions for the `input` group or run as root.\n\n2. **How can I run this automatically on boot?**  \n   Use the included systemd service file:\n\n   ```bash\n   sudo systemctl enable mouse-entropy.service\n   sudo systemctl start mouse-entropy.service\n   ```\n\n3. **How do I parse the raw .bin files without dumping to CSV?**  \n   Each record is 3 or 4 bytes. You can parse them in your own scripts if desired:\n\n   - Byte 0: Button bits.\n   - Byte 1: `dx` (signed).\n   - Byte 2: `dy` (signed).\n   - Byte 3 (optional): Zero padding if `store_4_bytes = true`.\n\n4. **Can I store data somewhere other than `data/`?**  \n   Yes, simply change the `base_directory` in `/etc/mouse-entropy/mouse-entropy.toml`.\n\n5. **What about security concerns with storing raw mouse data?**\n   - We store local files with restricted permissions (by default `0700` for directories, `0600` for files).\n   - If you’re worried about the sensitivity of this data, ensure you have appropriate backups and protections.\n\n---\n\n## Troubleshooting\n\n- **Permission Denied** when reading `/dev/input/mice`:  \n  Make sure you run as `root` or have read permissions on that device.\n- **No data is being generated**:  \n  Check system logs (`journalctl -u mouse-entropy.service`) or run in the foreground to see errors. Perhaps your device path is different from `/dev/input/mice`.\n- **Files are not rotating**:  \n  Confirm `max_file_size_mb` in your config. Large mouse inactivity means it might take a while to reach the threshold.\n\n---\n\n## Contributing\n\nContributions are welcome! To contribute:\n\n1. Fork the repository.\n2. Create a new branch for your feature/bug fix.\n3. Make and test your changes.\n4. Submit a Pull Request describing the changes.\n\nPlease open an issue first if you plan a significant change or need guidance.\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).  \nFeel free to use, modify, and distribute this software in accordance with the MIT license terms.\n\n---\n\n## Author / Maintainer\n\n- **Author**: [Anthony Therrien](https://github.com/anto18671)\n\nContributions by the open-source community are greatly appreciated.\n\n---\n\n## Acknowledgments\n\n- [Rust](https://www.rust-lang.org/) for making safe, performant CLIs easy.\n- [Arch Linux](https://archlinux.org/) for providing a lightweight, DIY approach that fosters tools like this.\n\nFeel free to leave a star on the [GitHub repository](https://github.com/anto18671/mouse-entropy) if you find this project useful!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanto18671%2Fmouse-entropy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanto18671%2Fmouse-entropy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanto18671%2Fmouse-entropy/lists"}