Skip to content

fprintkill is a simple POSIX shell script that allows you to launch any executable and have it terminated by fingerprint... especially useful for screen-lockers that do not support fingerprint unlocking.

Notifications You must be signed in to change notification settings

fraxflax/fprintkill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fprintkill

fprintkill is a POSIX shell script that allows you to launch any executable and have it terminated by fingerprint... especially useful for screen-lockers that do not support fingerprint unlocking.

I do like to use simple lightweight screen lockers like xtrlock or slock and have them launched by xautolock. They have low impact on the system and gives me full control to tweak exactly how I like them to work (have wrappers shutting off the screen, additional warnings before locking as yad dialogs, etc, etc).

BUT now that we have fingerprint readers on almost all laptops I also do want to be able to unlock my computer using that ... which those lockers do not support, not even via libpam-fprintd, so to fix that dilemma I wrote this small script fixing the problem.

INSTALL:
Just download the script (fprintkill), make it executable and stuck it in your path :-) e.g. like this:

curl -o /usr/local/bin/fprintkill https://raw.githubusercontent.com/fraxflax/fprintkill/main/fprintkill ; chmod a+rx /usr/local/bin/fprintkill

You might want to have fraxlock (from the examples folder) as well:

curl -o /usr/local/bin/fraxlock https://raw.githubusercontent.com/fraxflax/fprintkill/main/examples/fraxlock ; chmod a+rx /usr/local/bin/fraxlock

SYNOPSIS:
fprintkill [ cmd [ arg ...] ]

Executes cmd [ arg ...] and for as long as cmd is running, upon successfull fingerprint verify, cmd is terminated.

If no arguments are given to fprintkill, enviroment variables FPK_EXEC and FPK_ARGS are used for cmd [ arg ...]

EXIT STATUS:
fprintkill exits with the same code as the cmd. If cmd is terminated after fingerprint verify, fprintkill exits with the SIGTERM exit code (143 in linux).

DEPENDENCIES:
fprintkill will always launch the cmd, but the fingerprint termination depends on the following executables:
fprintd-verify, pgrep, pkill, ps, sed, & setsid
If they are not found in the path, a warning will be printed to stderr but the cmd will still be launched, even though it cannot be killed by fingerprint. (To satisfy the dependencies in Debian/Ubuntu: apt install util-linux procps sed fprintd util-linux).

EXAMPLES:
Lock the screen with slock, terminating it upon verified fingerprint:
fprintkill slock

Run '/usr/bin/xtrlock -b' in the background terminating it upon verified fingerprint:
fprintkill /usr/bin/xtrlock -b &

Alternative using environment variables:
env FPK_EXEC=/usr/bin/xtrlock FPK_ARGS=-b fprintkill &

Arguments with whitespaces are ok:
fprintkill sh -c "xset dpms force off ; xtrlock" &

Alternative using environment variables:
env FPK_EXEC=sh FPK_ARGS='-c "xset dpms force off ; xtrlock"' fprintkill &

Also daemons are properly handled. To launch xtrlock in the background as a daemon that will be terminated upon verified fingerprint:
fprintkill xtrlock -f

In the case the cmd is a daemon spawning several parallel processes (spawn) before exiting, all of the spawn will be monitored and terminated upon verified fingerprint. Cleanup will not be performed before all of the parallell processes have exited or have been terminated. In this example:
fprintkill sh -c "proc1 & proc2 & proc3 & exit 0"
... if proc1 exits, fprintkill will keep monitoring proc2 and proc3. If proc1, proc2 and proc3 all exits fprintkill will clean up. Upon verified fingerprint, proc1, proc2 and proc3 (and their child processes, if any) will be terminated (cleaned up).

SCRIPT EXAMPLES:
You can use fprintkill in "wrapper" scripts, e.g. /usr/local/bin/xtrlock

#!/bin/sh
EXEC=/usr/bin/xtrlock
test -x $EXEC || { 
    echo "Executable '$EXEC' not present!" >/dev/stderr
    exit 1
}
which fprintkill >/dev/null || exec $EXEC "$@"
eval "exec fprintkill $EXEC \"$@\""

having /usr/local/bin preceed /usr/bin in the path, the script becomes a transparent wrapper for xtrlock allowing unlocking using fingerprint.

Please, see the examples folder for more examples, including fraxlock, a nifty multilocker for different environments :-)
https://github.com/fraxflax/fprintkill/tree/main/examples

In the extras folder you can find some utilities making life easier enrolling / refreshing the fingerprind db. https://github.com/fraxflax/fprintkill/tree/main/extras

About

fprintkill is a simple POSIX shell script that allows you to launch any executable and have it terminated by fingerprint... especially useful for screen-lockers that do not support fingerprint unlocking.

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •  

Languages