Skip to content

Commit

Permalink
Make fingerprint feature optional
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum5 committed Dec 6, 2023
1 parent eb6c2be commit a124d1a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
20 changes: 18 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "wlr-screencopy-unstable-v1-client-protocol.h"
#include "ext-session-lock-v1-client-protocol.h"
#include "fingerprint/fingerprint.h"

#if HAVE_FINGERPRINT
# include "fingerprint/fingerprint.h"
#endif

// returns a positive integer in milliseconds
static uint32_t parse_seconds(const char *seconds) {
Expand Down Expand Up @@ -998,7 +1001,9 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
{"disable-caps-lock-text", no_argument, NULL, 'L'},
{"indicator-caps-lock", no_argument, NULL, 'l'},
{"line-uses-inside", no_argument, NULL, 'n'},
#if HAVE_FINGERPRINT
{"fingerprint", no_argument, NULL, 'p'},
#endif
{"line-uses-ring", no_argument, NULL, 'r'},
{"scaling", required_argument, NULL, 's'},
{"tiling", no_argument, NULL, 'T'},
Expand Down Expand Up @@ -1108,8 +1113,10 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
"Disable the Caps Lock text.\n"
" -l, --indicator-caps-lock "
"Show the current Caps Lock state also on the indicator.\n"
#if HAVE_FINGERPRINT
" -p, --fingerprint "
"Enable fingerprint scanning. Fprint is required.\n"
#endif
" -s, --scaling <mode> "
"Image scaling mode: stretch, fill, fit, center, tile, solid_color.\n"
" -T, --tiling "
Expand Down Expand Up @@ -1278,11 +1285,13 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
state->args.screenshots = true;
}
break;
#if HAVE_FINGERPRINT
case 'p':
if (state) {
state->args.fingerprint = true;
}
break;
#endif
case 'k':
if (state) {
state->args.show_keyboard_layout = true;
Expand Down Expand Up @@ -1794,6 +1803,7 @@ static void term_in(int fd, short mask, void *data) {
state.run_display = false;
}

#if HAVE_FINGERPRINT
static void check_fingerprint(void *d) {
struct FingerprintState *fingerprint_state = d;
if (fingerprint_verify(fingerprint_state)) {
Expand All @@ -1802,6 +1812,7 @@ static void check_fingerprint(void *d) {

loop_add_timer(state.eventloop, 300, check_fingerprint, fingerprint_state);
}
#endif

// Check for --debug 'early' we also apply the correct loglevel
// to the forked child, without having to first proces all of the
Expand Down Expand Up @@ -2030,11 +2041,13 @@ int main(int argc, char **argv) {

loop_add_timer(state.eventloop, 1000, timer_render, &state);

#if HAVE_FINGERPRINT
struct FingerprintState fingerprint_state;
if (state.args.fingerprint) {
fingerprint_init(&fingerprint_state, &state);
loop_add_timer(state.eventloop, 100, check_fingerprint, &fingerprint_state);
}
#endif

if (state.args.fade_in) {
loop_add_timer(state.eventloop, state.args.fade_in, end_allow_fade_period, &state);
Expand Down Expand Up @@ -2070,9 +2083,12 @@ int main(int argc, char **argv) {
wl_display_roundtrip(state.display);
}

if(state.args.fingerprint) {
#if HAVE_FINGERPRINT
if (state.args.fingerprint) {
fingerprint_deinit(&fingerprint_state);
}
#endif

free(state.args.font);
return 0;
}
10 changes: 7 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ conf_data = configuration_data()
conf_data.set_quoted('SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
conf_data.set_quoted('SWAYLOCK_VERSION', version)
conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
conf_data.set10('HAVE_FINGERPRINT', get_option('fingerprint').enabled())

subdir('include')
subdir('fingerprint')

dependencies = [
cairo,
Expand All @@ -103,8 +103,7 @@ dependencies = [
dl,
xkbcommon,
wayland_client,
omp,
fingerprint
omp
]

sources = [
Expand All @@ -124,6 +123,11 @@ sources = [
'fade.c',
]

if get_option('fingerprint').enabled()
subdir('fingerprint')
dependencies += [fingerprint]
endif

if libpam.found()
sources += ['pam.c']
dependencies += [libpam]
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ option('zsh-completions', type: 'boolean', value: true, description: 'Install zs
option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions')
option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions')
option('sse', type: 'boolean', value: true, description: 'Use SSE instructions where possible')
option('fingerprint', type: 'feature', value: 'auto', description: 'Enable fingerprint support')

0 comments on commit a124d1a

Please sign in to comment.