From 18851d411ea52d68bc64c32a9ad4fec9b004a8a2 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Sun, 14 Jun 2020 03:03:00 -0700 Subject: [PATCH] Added --search --- man/wofi.1 | 3 +++ man/wofi.5 | 3 +++ src/main.c | 16 +++++++++++++++- src/wofi.c | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/man/wofi.1 b/man/wofi.1 index 68c52ce..9212676 100644 --- a/man/wofi.1 +++ b/man/wofi.1 @@ -106,6 +106,9 @@ Specifies the default sort order. There are currently two orders, default and al .TP .B \-G, \-\-gtk\-dark Instructs wofi to use the dark variant of the current GTK theme, if available. +.TP +.B \-Q, \-\-search +Specifies something to search for immediately on opening .SH CONFIGURATION Wofi has 3 main files used for configuration. All files are completely optional. diff --git a/man/wofi.5 b/man/wofi.5 index 3a06511..ac936e9 100644 --- a/man/wofi.5 +++ b/man/wofi.5 @@ -103,6 +103,9 @@ Specifies the default sort order. There are currently two orders, default and al .B gtk_dark=\fIBOOL\fR If true, instructs wofi to use the dark variant of the current GTK theme (if available). Default is false. .TP +.B search=\fISTRING\f +Specifies something to search for immediately on opening +.TP .B orientation=\fIORIENTATION\fR Specifies the orientation, it can be either horizontal or vertical, default is vertical. .TP diff --git a/src/main.c b/src/main.c index b9a188a..1fec6d3 100644 --- a/src/main.c +++ b/src/main.c @@ -94,6 +94,7 @@ static void print_usage(char** argv) { printf("--columns\t-w\tSets the number of columns to display\n"); printf("--sort-order\t-O\tSets the sort order\n"); printf("--gtk-dark\t-G\tUses the dark variant of the current GTK theme\n"); + printf("--search\t-Q\tSearch for something immediately on open\n"); exit(0); } @@ -407,6 +408,12 @@ int main(int argc, char** argv) { .flag = NULL, .val = 'G' }, + { + .name = "search", + .has_arg = no_argument, + .flag = NULL, + .val = 'Q' + }, { .name = NULL, .has_arg = 0, @@ -441,13 +448,14 @@ int main(int argc, char** argv) { char* columns = NULL; char* sort_order = NULL; char* gtk_dark = NULL; + char* search = NULL; struct wl_list options; wl_list_init(&options); struct option_node* node; int opt; - while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:L:w:O:G", opts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:L:w:O:GQ:", opts, NULL)) != -1) { switch(opt) { case 'h': print_usage(argv); @@ -550,6 +558,9 @@ int main(int argc, char** argv) { case 'G': gtk_dark = "true"; break; + case 'Q': + search = optarg; + break; } } @@ -733,6 +744,9 @@ int main(int argc, char** argv) { if(sort_order != NULL) { map_put(config, "sort_order", sort_order); } + if(search != NULL) { + map_put(config, "search", search); + } struct sigaction sigact = {0}; sigact.sa_handler = sig; diff --git a/src/wofi.c b/src/wofi.c index 857a633..fcc9309 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -1519,6 +1519,7 @@ void wofi_init(struct map* _config) { line_wrap = config_get_mnemonic(config, "line_wrap", "off", 4, "off", "word", "char", "word_char") - 1; bool global_coords = strcmp(config_get(config, "global_coords", "false"), "true") == 0; bool hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0; + char* search = map_get(config, "search"); keys = map_init_void(); @@ -1643,6 +1644,10 @@ void wofi_init(struct map* _config) { gtk_container_add(GTK_CONTAINER(outer_box), entry); gtk_widget_set_child_visible(entry, !hide_search); + if(search != NULL) { + gtk_entry_set_text(GTK_ENTRY(entry), search); + } + if(password_char != NULL) { gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); gtk_entry_set_invisible_char(GTK_ENTRY(entry), password_char[0]);