Skip to content

Commit 08e23f1

Browse files
committed
Add test mode
1 parent 32d8f75 commit 08e23f1

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

include/gtklock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct GtkLock {
3939
char *unlock_command;
4040

4141
GArray *modules;
42+
43+
gboolean test_mode;
4244
};
4345

4446
void gtklock_remove_window(struct GtkLock *gtklock, struct Window *win);

src/source.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static gboolean should_daemonize = FALSE;
4040
static gboolean follow_focus = FALSE;
4141
static gboolean idle_hide = FALSE;
4242
static gboolean start_hidden = FALSE;
43+
static gboolean test_mode = FALSE;
4344

4445
static gint idle_timeout = 15;
4546

@@ -59,6 +60,7 @@ static GOptionEntry main_entries[] = {
5960
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, "Show version", NULL },
6061
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config_path, "Load config file", NULL },
6162
{ "daemonize", 'd', 0, G_OPTION_ARG_NONE, &should_daemonize, "Detach from controlling terminal", NULL },
63+
{ "preview", 'p', 0, G_OPTION_ARG_NONE, &test_mode, "Enable preview mode where any password can unlock", NULL },
6264
{ NULL },
6365
};
6466

@@ -343,6 +345,7 @@ int main(int argc, char **argv) {
343345

344346
gtklock->hidden = start_hidden;
345347
gtklock->idle_timeout = (guint)idle_timeout;
348+
gtklock->test_mode = test_mode;
346349

347350
gtklock->follow_focus = follow_focus;
348351
gtklock->use_idle_hide = idle_hide;

src/window.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ static gboolean window_pw_message(gpointer data) {
143143
}
144144

145145
static gpointer window_pw_wait(gpointer data) {
146+
if (gtklock->test_mode) {
147+
g_application_quit(G_APPLICATION(gtklock->app));
148+
}
146149
struct Window *ctx = data;
147150
const char *password = gtk_entry_get_text((GtkEntry*)ctx->input_field);
148151
while(TRUE) {

0 commit comments

Comments
 (0)