Last active
February 27, 2026 23:38
-
-
Save Speyll/b7803161b1ee43f258d484fe9e92c4b4 to your computer and use it in GitHub Desktop.
Robust udev rule generator for ATK/VXE mice and keyboards on Linux. Enables WebUSB access for ATK HUB (hub.atk.pro) and generic raw HID access. Supports multiple Vendor IDs (373b, 3554) and automates group permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| RULE_FILE="/etc/udev/rules.d/99-atk-mouse.rules" | |
| ATK_VIDS=("373b" "3554" "25a7") | |
| echo "π Launching Clean ATK Setup (Group-Free)..." | |
| # 1. Root check | |
| if [[ $EUID -ne 0 ]]; then | |
| echo "β Please run as root (sudo)." | |
| exit 1 | |
| fi | |
| # 2. Write rules atomically using mktemp | |
| echo "π Writing pure permission rules..." | |
| TMP_RULE="$(mktemp)" | |
| cat > "$TMP_RULE" << 'EOF' | |
| # ------------------------------------------------------------ | |
| # ATK / VXE / VGN Hub Rules (Product Agnostic, Group-Free) | |
| # ------------------------------------------------------------ | |
| EOF | |
| # Loop through VIDs and apply rules without any GROUP assignment | |
| for VID in "${ATK_VIDS[@]}"; do | |
| cat >> "$TMP_RULE" <<EOF | |
| # Vendor: $VID | |
| # ATTRS{idProduct}=="*" anchors to the parent without hardcoding the specific ID | |
| KERNEL=="hidraw*", ATTRS{idVendor}=="$VID", ATTRS{idProduct}=="*", MODE:="0666", TAG+="uaccess" | |
| EOF | |
| done | |
| # Add a generic fallback | |
| cat >> "$TMP_RULE" << 'EOF' | |
| # Generic HID Fallback | |
| SUBSYSTEM=="hidraw", ENV{ID_INPUT_MOUSE}=="1", MODE:="0666", TAG+="uaccess" | |
| EOF | |
| # Install securely | |
| install -m 0644 "$TMP_RULE" "$RULE_FILE" | |
| rm -f "$TMP_RULE" | |
| # 3. Reload udev immediately | |
| echo "π Reloading udev rules..." | |
| udevadm control --reload-rules | |
| udevadm trigger | |
| echo "β¨ Done." | |
| echo "β‘οΈ ACTION REQUIRED: Unplug and replug your mouse now." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment