Skip to content

Instantly share code, notes, and snippets.

@dmarrazzo
Created May 2, 2025 08:23
Show Gist options
  • Select an option

  • Save dmarrazzo/697fbe768f87e4ff99f2fec41889b61a to your computer and use it in GitHub Desktop.

Select an option

Save dmarrazzo/697fbe768f87e4ff99f2fec41889b61a to your computer and use it in GitHub Desktop.
How to dynamically disable fingerprint reader when the laptop is plugged in the thunderbold docking station

How to dynamically disable fingerprint reader when the laptop is plugged in the thunderbold docking station

Create the script handler

Create and edit the script:

sudo vi /usr/local/bin/thunderbolt-handler.sh

Add the following content:

#!/bin/bash

if [ "$1" == "add" ]; then
    logger "Thunderbolt device plugged in!"
    authselect disable-feature with-fingerprint
    echo "Thunderbolt device plugged in"
elif [ "$1" == "remove" ]; then
    logger "Thunderbolt device unplugged!"
    authselect enable-feature with-fingerprint
    echo "Thunderbolt device unplugged"
else
    echo "Unknown argument: $1"
fi

Grant execution permessions:

sudo chmod +x /usr/local/bin/thunderbolt-handler.sh

Create a udev rule

Create a new rule in /etc/udev/rules.d/99-thunderbolt.rules:

sudo vi /etc/udev/rules.d/99-thunderbolt.rules

Paste this:

SUBSYSTEM=="thunderbolt", ACTION=="add", RUN+="/usr/local/bin/thunderbolt-handler.sh add"
SUBSYSTEM=="thunderbolt", ACTION=="remove", RUN+="/usr/local/bin/thunderbolt-handler.sh remove"

Reload udev and test

Reload rules and trigger:

sudo udevadm control --reload-rules
sudo udevadm trigger

Then unplug and replug your Thunderbolt device to test.

Debugging Tips

  • Check if the rule fired using:

    journalctl -xe | grep thunderbolt

    Use ENV{ID_MODEL} or similar to narrow the match.

  • Identify your Thunderbolt device running:

    udevadm monitor --environment --udev

    Plug in your Thunderbolt device and check the events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment