Skip to content

Instantly share code, notes, and snippets.

@mca-gif
Last active November 14, 2025 04:22
Show Gist options
  • Select an option

  • Save mca-gif/095d94bb211678bd5391a21aaff06cbd to your computer and use it in GitHub Desktop.

Select an option

Save mca-gif/095d94bb211678bd5391a21aaff06cbd to your computer and use it in GitHub Desktop.
Ubuntu 24.04 - Enable / Disable Fingerprint Reader with Laptop Lid

Use the files here and the steps below to configure a laptop to enable and disable fingerprint auth support in PAM when the lid is opened or closed.

NOTE: Currently not working is setting the correct state when the machine first boots. It is just whatever is last.

Setup Requirements

  • Install acpid
  • Enable acpid
$ sudo apt install --assume-yes acpid
$ sudo systemctl enable --now acpid

Configure acpid

  • Download the config file and bash script and install them into /etc/acpid
$ sudo install -D --owner=root --group=root --mode=0644 laptop-lid /etc/acpid/events/laptop-lid
$ sudo install -D --owner=root --group=root --mode=0744 laptop-lid.sh /etc/acpid/laptop-lid.sh
$ sudo systemctl restart acpid

Test

  • Open lid and in a new terminal attempt to use sudo:
~ $ sudo bash
Place your finger on the fingerprint reader
  • Close lid and in a new terminal attempt to use sudo:
~ $ sudo bash
[sudo] password for user: 
event=button/lid.*
action=/etc/acpi/laptop-lid.sh "%e"
#!/bin/bash
# Function to get the lid state
get_lid_state() {
for lid in /proc/acpi/button/lid/*; do
if [ -d "$lid" ]; then
state=$(cat "$lid/state" | awk '{print $2}')
echo "$state"
fi
done
}
# Check all lid states
LID_STATES=$(get_lid_state)
if echo "$LID_STATES" | grep -q "closed"; then
# Disable fprintd profile if any lid is closed
echo "Disabling fprintd with pam-auth-update because at least one lid is closed."
pam-auth-update --disable fprintd
logger "fprintd disabled because at least one lid is closed"
elif echo "$LID_STATES" | grep -q "open"; then
# Enable fprintd profile if all lids are open
echo "Enabling fprintd with pam-auth-update because all lids are open."
pam-auth-update --enable fprintd
logger "fprintd enabled because all lids are open"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment