diff --git a/include/gtklock.h b/include/gtklock.h index 64c2f72..f427df1 100644 --- a/include/gtklock.h +++ b/include/gtklock.h @@ -39,6 +39,8 @@ struct GtkLock { char *unlock_command; GArray *modules; + + gboolean test_mode; }; void gtklock_remove_window(struct GtkLock *gtklock, struct Window *win); diff --git a/src/source.c b/src/source.c index ad2ac22..e5724dc 100644 --- a/src/source.c +++ b/src/source.c @@ -40,6 +40,7 @@ static gboolean should_daemonize = FALSE; static gboolean follow_focus = FALSE; static gboolean idle_hide = FALSE; static gboolean start_hidden = FALSE; +static gboolean test_mode = FALSE; static gint idle_timeout = 15; @@ -59,6 +60,7 @@ static GOptionEntry main_entries[] = { { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, "Show version", NULL }, { "config", 'c', 0, G_OPTION_ARG_FILENAME, &config_path, "Load config file", NULL }, { "daemonize", 'd', 0, G_OPTION_ARG_NONE, &should_daemonize, "Detach from controlling terminal", NULL }, + { "preview", 'p', 0, G_OPTION_ARG_NONE, &test_mode, "Enable preview mode where any password can unlock", NULL }, { NULL }, }; @@ -343,6 +345,7 @@ int main(int argc, char **argv) { gtklock->hidden = start_hidden; gtklock->idle_timeout = (guint)idle_timeout; + gtklock->test_mode = test_mode; gtklock->follow_focus = follow_focus; gtklock->use_idle_hide = idle_hide; diff --git a/src/window.c b/src/window.c index b5859cb..9794ee2 100644 --- a/src/window.c +++ b/src/window.c @@ -143,6 +143,9 @@ static gboolean window_pw_message(gpointer data) { } static gpointer window_pw_wait(gpointer data) { + if (gtklock->test_mode) { + g_application_quit(G_APPLICATION(gtklock->app)); + } struct Window *ctx = data; const char *password = gtk_entry_get_text((GtkEntry*)ctx->input_field); while(TRUE) {