Skip to content

Instantly share code, notes, and snippets.

@numpde
Last active October 19, 2025 09:59
Show Gist options
  • Select an option

  • Save numpde/48d6f44d22a35e391064a102d0b5afda to your computer and use it in GitHub Desktop.

Select an option

Save numpde/48d6f44d22a35e391064a102d0b5afda to your computer and use it in GitHub Desktop.
Disables the power and sleep keys on the ROG Falchion keyboard via udev hwdb rules.
#!/bin/bash
# Disable bogus Power/Sleep/Wakeup from "ASUSTeK ROG FALCHION System Control"
# Requires: systemd-hwdb (or udevadm hwdb), udevadm
set -euo pipefail
hwdb_update(){ command -v systemd-hwdb &>/dev/null && systemd-hwdb update || udevadm hwdb --update; }
(( EUID == 0 )) || { echo "Run as root (sudo)"; exit 1; }
echo "[1/6] Locating 'ASUSTeK ROG FALCHION System Control'…"
evnode=""
for p in /sys/class/input/event*/device/name; do
[[ -f "$p" ]] && grep -qx "ASUSTeK ROG FALCHION System Control" "$p" && {
evnode="$(sed 's|/sys/class/input/\(event[0-9]\+\)/device/name|\1|' <<<"$p")"; break; }
done
[[ -n "${evnode:-}" ]] || { echo "Not found. Connect the keyboard/dongle."; exit 1; }
echo " Found: /dev/input/$evnode"
echo "[2/6] Reading udev properties…"
props="$(udevadm info --query=property --path="/sys/class/input/$evnode")"
vid="$(grep -oP '^ID_VENDOR_ID=\K[0-9a-fA-F]+' <<<"$props")"
pid="$(grep -oP '^ID_MODEL_ID=\K[0-9a-fA-F]+' <<<"$props")"
[[ -n "$vid" && -n "$pid" ]] || { echo "Couldn’t get VID/PID"; exit 1; }
bus="0003"; VID="${vid^^}"; PID="${pid^^}"
echo " VID=0x$VID PID=0x$PID BUS=0x$bus"
echo "[3/6] Writing hwdb (two stanzas; one blank line between)…"
mkdir -p /etc/udev/hwdb.d
hwdb_file="/etc/udev/hwdb.d/99-rog-falchion-system-control.hwdb"
cat >"$hwdb_file" <<EOF
evdev:input:b${bus}v${VID}p${PID}e0111*
KEYBOARD_KEY_00010081=reserved
KEYBOARD_KEY_10081=reserved
KEYBOARD_KEY_00010082=reserved
KEYBOARD_KEY_10082=reserved
KEYBOARD_KEY_00010083=reserved
KEYBOARD_KEY_10083=reserved
KEYBOARD_KEY_0c0081=reserved
KEYBOARD_KEY_0c0082=reserved
KEYBOARD_KEY_0c0083=reserved
evdev:input:b*v${VID}p${PID}*
KEYBOARD_KEY_00010081=reserved
KEYBOARD_KEY_10081=reserved
KEYBOARD_KEY_00010082=reserved
KEYBOARD_KEY_10082=reserved
KEYBOARD_KEY_00010083=reserved
KEYBOARD_KEY_10083=reserved
KEYBOARD_KEY_0c0081=reserved
KEYBOARD_KEY_0c0082=reserved
KEYBOARD_KEY_0c0083=reserved
EOF
echo " Wrote: $hwdb_file"
echo "[4/6] Compiling and triggering…"
hwdb_update
udevadm trigger -s input
echo "[5/6] Verifying hwdb match against $evnode…"
udevadm test-builtin hwdb "/sys/class/input/$evnode/device" 2>&1 | sed -n \
-e 's/.*\(input:b.*modalias key:.*\)/\1/p' \
-e 's/.*\(KEYBOARD_KEY_.*\)/\1/p'
cat <<'EOF'
[6/6] Next:
- Unplug/replug the USB dongle or power-cycle the keyboard once (needed to rebind).
- Test: sudo evtest /dev/input/<eventN-for-System-Control> (toggle keyboard power)
Expected: no EV_KEY KEY_POWER / KEY_SLEEP / KEY_WAKEUP.
If keys still appear:
- Paste the "input:b..." modalias from the verify step and the MSC_SCAN codes from evtest
(they sometimes show as 0c0081/82/83 on Consumer page). We'll add any missing entries.
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment