Fast, lightweight battery monitor for Angry Miao INFINITY 8K Mouse with support for both mouse and spare battery (in charging dock).
- 17KB binary - Minimal resource usage
- <100ms execution time - Fast polling
- Dual battery support - Monitor both mouse and spare battery
- Direct hidraw access - Uses Linux kernel HID interface via ioctl
makeThis creates the read_battery executable (~17KB).
Grant permission to access the HID device without root:
sudo cp udev/99-angry-miao-mouse.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm triggerUnplug and replug your mouse (or reboot) for the rule to take effect.
./read_battery -bExpected output: 100 50 (mouse battery, then spare battery)
# Mouse battery only (default)
./read_battery
# Output: 100
# Spare battery only
./read_battery -s
# Output: 50
# Both batteries
./read_battery -b
# Output: 100 50
# Verbose mode (for debugging)
./read_battery -vThe HID report contains battery data at these byte positions:
- Byte 2: Mouse battery percentage (0-100)
- Byte 10: Spare battery percentage (0-100)
| Metric | Value |
|---|---|
| Binary size | 17 KB |
| Execution time | ~100ms |
| Memory usage | <1 MB |
| Dependencies | None (libc only) |
- Scans
/sys/class/hidraw/*/device/ueventfor Angry Miao mouse (VID:PID = 3151:5007, interface 2) - Opens
/dev/hidraw*device withO_RDWR - Sends HID feature report initialization (report ID 0x00, command 0xF7)
- Reads HID feature report 0xF7 (65 bytes)
- Extracts battery percentages from bytes 2 and 10
read_battery.c- Main C source codeMakefile- Build configurationmiaobat- Compiled binary (aftermake)99-angry-miao-mouse.rules- udev rule for permissions
Make sure the udev rule is installed and the mouse has been replugged:
ls -l /dev/hidraw* | grep 3151You should see crw-rw-rw- permissions on the relevant hidraw device.
Check if the mouse is connected and detected:
lsusb | grep 3151
./read_battery -vMake sure you have gcc and kernel headers:
sudo pacman -S gcc linux-headers # Arch
sudo apt install gcc linux-headers-$(uname -r) # Debian/Ubuntusudo make installThis installs to /usr/local/bin/read_battery.
sudo make uninstall
sudo rm /etc/udev/rules.d/99-angry-miao-mouse.rules