From c567dbffaa222891535e187cec44bbbd4a51b15e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 9 Jul 2025 20:46:43 -0400 Subject: [PATCH] Only allow fingerprint setup if a sensor is detected --- bin/omarchy-fingerprint-setup | 48 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/bin/omarchy-fingerprint-setup b/bin/omarchy-fingerprint-setup index 48e5bca..98b8af3 100755 --- a/bin/omarchy-fingerprint-setup +++ b/bin/omarchy-fingerprint-setup @@ -1,15 +1,18 @@ #!/bin/bash -yay -S --noconfirm --needed fprintd libfprint +yay -S --noconfirm --needed fprintd libfprint lsusb -# Add fingerprint authentication as an option for sudo -if ! grep -q pam_fprintd.so /etc/pam.d/sudo; then - sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/sudo -fi +if ! lsusb | grep -iq fingerprint; then + echo "No fingerprint sensor detected." +else + # Add fingerprint authentication as an option for sudo + if ! grep -q pam_fprintd.so /etc/pam.d/sudo; then + sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/sudo + fi -# Add fingerprint authentication as an option for hyprpolkitagent -if [ ! -f /etc/pam.d/polkit-1 ] || ! grep -q pam_fprintd.so /etc/pam.d/polkit-1; then - sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF' + # Add fingerprint authentication as an option for hyprpolkitagent + if [ ! -f /etc/pam.d/polkit-1 ] || ! grep -q pam_fprintd.so /etc/pam.d/polkit-1; then + sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF' auth required pam_unix.so auth optional pam_fprintd.so @@ -17,18 +20,19 @@ account required pam_unix.so password required pam_unix.so session required pam_unix.so EOF -fi - -systemctl --user restart hyprpolkitagent - -# Enroll the first finger -echo -e "\e[32m\nLet's setup your right index finger as the first fingerprint.\nKeep moving the finger around on sensor until the process completes.\n\e[0m" -sudo fprintd-enroll $USER - -echo -e "\e[32m\nNow let's verify that it's working correctly.\e[0m\n" - -if fprintd-verify; then - echo -e "\e[32m\nPerfect! Now you can use your fingerprint on the lock screen (Super + Escape).\e[0m" -else - echo -e "\e[31m\nSomething went wrong. Maybe try again?\e[0m" + fi + + systemctl --user restart hyprpolkitagent + + # Enroll the first finger + echo -e "\e[32m\nLet's setup your right index finger as the first fingerprint.\nKeep moving the finger around on sensor until the process completes.\n\e[0m" + sudo fprintd-enroll $USER + + echo -e "\e[32m\nNow let's verify that it's working correctly.\e[0m\n" + + if fprintd-verify; then + echo -e "\e[32m\nPerfect! Now you can use your fingerprint on the lock screen (Super + Escape).\e[0m" + else + echo -e "\e[31m\nSomething went wrong. Maybe try again?\e[0m" + fi fi