Skip to content

Instantly share code, notes, and snippets.

@Speyll
Last active February 27, 2026 23:38
Show Gist options
  • Select an option

  • Save Speyll/b7803161b1ee43f258d484fe9e92c4b4 to your computer and use it in GitHub Desktop.

Select an option

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.
#!/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