Last active
February 3, 2025 19:00
-
-
Save numpde/3a9b665779b570e612cf92d751af366b to your computer and use it in GitHub Desktop.
This script detects the ROG Falchion System Control input device and creates a udev rule to disable it under Wayland. It then reloads udev rules and optionally reboots the system.
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 -e # Exit on error | |
# Ensure script is run as root | |
if [[ $EUID -ne 0 ]]; then | |
echo "Error: This script must be run as root (use sudo)." >&2 | |
exit 1 | |
fi | |
echo "Detecting ROG Falchion System Control device..." | |
# Find the exact device name using libinput | |
DEVICE_NAME=$(libinput list-devices | grep -E -A 1 "ASUSTeK ROG FALCHION System Control" | grep -Eo "Device:\s+.*" | awk -F 'Device: ' '{print $2}') | |
if [[ -z "$DEVICE_NAME" ]]; then | |
echo "Error: ROG Falchion System Control device not found. Ensure it is connected." >&2 | |
exit 1 | |
fi | |
echo "Detected device: '$DEVICE_NAME'" | |
# Define udev rule file | |
UDEV_FILE="/etc/udev/rules.d/99-disable-falchion-system-control.rules" | |
UDEV_RULE="SUBSYSTEM==\"input\", ATTRS{name}==\"$DEVICE_NAME\", ENV{LIBINPUT_IGNORE_DEVICE}=\"1\"" | |
# Check if the rule already exists | |
if [[ -f "$UDEV_FILE" ]] && grep -Fxq "$UDEV_RULE" "$UDEV_FILE"; then | |
echo "The udev rule is already in place. No changes needed." | |
else | |
echo "Creating udev rule to disable '$DEVICE_NAME'..." | |
echo "$UDEV_RULE" | tee "$UDEV_FILE" > /dev/null | |
fi | |
# Apply the changes | |
echo "Applying udev rules..." | |
udevadm control --reload-rules | |
udevadm trigger | |
# Verify if the device is now ignored | |
echo "Verifying that the device is ignored..." | |
if libinput list-devices | grep -q "$DEVICE_NAME"; then | |
echo "Warning: Device still appears in libinput. A reboot may be required." >&2 | |
NEEDS_REBOOT=1 | |
else | |
echo "Success! The device is now ignored by libinput." | |
NEEDS_REBOOT=0 | |
fi | |
# Prompt for reboot only if necessary | |
if [[ $NEEDS_REBOOT -eq 1 ]]; then | |
read -p "Reboot now for changes to fully take effect? (y/N): " REBOOT | |
if [[ "$REBOOT" =~ ^[Yy]$ ]]; then | |
echo "Rebooting..." | |
reboot | |
else | |
echo "Reboot later to apply changes." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment