
To disable fingerprint authentication when the laptop lid is closed, and re-enable when it is reopened, we will use acpid
to bind to the button/lid.*
event to a custom script that will stop and mask the fprintd
service on lid close, and unmask and start the fprintd
service on lid open.
We also check that the HDMI cable is connected by testing the contents of /sys/class/drm/card0-HDMI-A-1/status
.
Follow the steps below:
- Create file
/etc/acpi/laptop-lid.sh
with the following contents:#!/bin/bash lock=$HOME/fprint-disabled if grep -Fq closed /proc/acpi/button/lid/LID0/state && grep -Fxq connected /sys/class/drm/card0-HDMI-A-1/status then touch "$lock" systemctl stop fprintd systemctl mask fprintd elif [ -f "$lock" ] then systemctl unmask fprintd systemctl start fprintd rm "$lock" fi
- Make the file executable with
chmod +x /etc/acpi/laptop-lid.sh
- Create file
/etc/acpi/events/laptop-lid
with the following contents:event=button/lid.* action=/etc/acpi/laptop-lid.sh
- Restart the
acpid
service with:sudo service acpid restart
Now the fingerprint will be used only when the lid is open.
In order to restore the correct state of the fprintd
service if you disconnect/reconnect while the laptop is off, you may call the above script from a systemd
init file. The steps to do this are the following:
- Create a file named
/etc/systemd/system/laptop-lid.service
with the following contents:[Unit] Description=Laptop Lid After=suspend.target [Service] ExecStart=/etc/acpi/laptop-lid.sh [Install] WantedBy=multi-user.target WantedBy=suspend.target
- Reload the systemd config files with
sudo systemctl daemon-reload
- Start the service with
sudo systemctl start laptop-lid.service
- Enable the service so that it starts automatically on boot
sudo systemctl enable laptop-lid.service
Now the status should be correct even after connecting/disconnecting when the computer is off.
Bron: https://unix.stackexchange.com
Je moet ingelogd zijn om een reactie te plaatsen.