Last active
January 31, 2025 17:00
-
-
Save numpde/db304f7a27589defe2912eac37bc33b4 to your computer and use it in GitHub Desktop.
This script disables USB autosuspend for the ASUS ROG FALCHION keyboard persistently by creating a udev rule, reloading the rules, and verifying the change.
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
#!/bin/bash | |
set -euo pipefail | |
# ASUS ROG FALCHION USB Vendor and Product ID | |
VENDOR_ID="0b05" | |
PRODUCT_ID="193e" | |
# Udev rule file path | |
RULE_FILE="/etc/udev/rules.d/99-rog-falchion.rules" | |
echo "Disabling USB autosuspend for ASUS ROG FALCHION (ID $VENDOR_ID:$PRODUCT_ID)..." | |
# Check if the rule already exists | |
if grep -q "$VENDOR_ID.*$PRODUCT_ID" "$RULE_FILE" 2>/dev/null; then | |
echo "Udev rule already exists. Skipping update." | |
else | |
echo 'ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="'$VENDOR_ID'", ATTRS{idProduct}=="'$PRODUCT_ID'", ATTR{power/control}="on"' | sudo tee "$RULE_FILE" > /dev/null | |
echo "Udev rule added: $RULE_FILE" | |
fi | |
# Reload udev rules | |
echo "Reloading udev rules..." | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger | |
# Find the correct device path dynamically | |
DEVICE_PATH=$(ls -d /sys/bus/usb/devices/* | while read -r dir; do | |
if [[ -f "$dir/idProduct" ]] && [[ -f "$dir/idVendor" ]]; then | |
if [[ "$(cat "$dir/idProduct")" == "$PRODUCT_ID" ]] && [[ "$(cat "$dir/idVendor")" == "$VENDOR_ID" ]]; then | |
echo "$dir" | |
break | |
fi | |
fi | |
done) | |
if [[ -n "$DEVICE_PATH" ]]; then | |
AUTOSUSPEND_STATE=$(cat "$DEVICE_PATH/power/control") | |
echo "Current autosuspend state: $AUTOSUSPEND_STATE" | |
if [[ "$AUTOSUSPEND_STATE" == "on" ]]; then | |
echo "✔ USB autosuspend is disabled for ASUS ROG FALCHION." | |
else | |
echo "⚠ Warning: USB autosuspend may not be disabled. Check manually." | |
fi | |
else | |
echo "⚠ Device not found. The rule will apply when the keyboard is reconnected." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment