Skip to content

Instantly share code, notes, and snippets.

@pipelinedave
Created June 25, 2023 18:54
Show Gist options
  • Save pipelinedave/802c3d797eebb229a8b05a6f8780b72a to your computer and use it in GitHub Desktop.
Save pipelinedave/802c3d797eebb229a8b05a6f8780b72a to your computer and use it in GitHub Desktop.
create udev rule to disable built-in device on bluetooth connection, e.g. disable laptop keyboard when bluetooth keyboard is connected
#!/bin/bash
# Prompt for the device event number
read -p "Enter the device event number: " event_number
# Display udev rules
udevadm info --attribute-walk --path=$(udevadm info --query=path --name=/dev/input/event${event_number})
read -p "Enter the KERNELS value: " kernels_value
read -p "Enter the SUBSYSTEMS value: " subsystems_value
read -p "Enter the ATTRS{id/product} value: " id_product_value
read -p "Enter the ATTRS{id/vendor} value: " id_vendor_value
read -p "Enter the ATTRS{id/version} value: " id_version_value
# Create the udev rule
sudo bash -c "echo 'KERNELS==\"${kernels_value}\", SUBSYSTEMS==\"${subsystems_value}\", ATTRS{id/product}==\"${id_product_value}\", ATTRS{id/vendor}==\"${id_vendor_value}\", ATTRS{id/version}==\"${id_version_value}\", ENV{LIBINPUT_IGNORE_DEVICE}=\"1\"' > /etc/udev/rules.d/99-ignore-my-device.rules"
echo "Rebooting your device is required for the changes to take effect."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment