diff --git a/modes/dmenu.c b/modes/dmenu.c index e7bebb3..52d401c 100644 --- a/modes/dmenu.c +++ b/modes/dmenu.c @@ -52,19 +52,21 @@ void wofi_dmenu_init(struct mode* this, struct map* config) { struct map* entry_map = map_init(); - char* line = NULL; - size_t size = 0; - while(getdelim(&line, &size, separator[0], stdin) != -1) { - char* delim = strchr(line, separator[0]); - if(delim != NULL) { - *delim = 0; + if(!isatty(STDIN_FILENO)) { + char* line = NULL; + size_t size = 0; + while(getdelim(&line, &size, separator[0], stdin) != -1) { + char* delim = strchr(line, separator[0]); + if(delim != NULL) { + *delim = 0; + } + struct cache_line* node = malloc(sizeof(struct cache_line)); + node->line = strdup(line); + wl_list_insert(&entries, &node->link); + map_put(entry_map, line, "true"); } - struct cache_line* node = malloc(sizeof(struct cache_line)); - node->line = strdup(line); - wl_list_insert(&entries, &node->link); - map_put(entry_map, line, "true"); + free(line); } - free(line); if(!print_line_num) { struct wl_list* cache = wofi_read_cache(mode); diff --git a/src/wofi.c b/src/wofi.c index b9b31a9..3bddf1c 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -1235,27 +1235,6 @@ static struct mode* add_mode(char* _mode) { return mode_ptr; } -static void* start_thread(void* data) { - char* mode = data; - - struct wl_list* modes = malloc(sizeof(struct wl_list)); - wl_list_init(modes); - - if(strchr(mode, ',') != NULL) { - char* save_ptr; - char* str = strtok_r(mode, ",", &save_ptr); - do { - struct mode* mode_ptr = add_mode(str); - wl_list_insert(modes, &mode_ptr->link); - } while((str = strtok_r(NULL, ",", &save_ptr)) != NULL); - } else { - struct mode* mode_ptr = add_mode(mode); - wl_list_insert(modes, &mode_ptr->link); - } - gdk_threads_add_idle(insert_all_widgets, modes); - return NULL; -} - static void parse_mods(char** key, char** mod) { char* hyphen = strchr(*key, '-'); if(hyphen != NULL) { @@ -1509,8 +1488,22 @@ void wofi_init(struct map* _config) { gdk_threads_add_timeout(70, do_percent_size, geo_str); } - pthread_t thread; - pthread_create(&thread, NULL, start_thread, mode); + struct wl_list* modes = malloc(sizeof(struct wl_list)); + wl_list_init(modes); + + if(strchr(mode, ',') != NULL) { + char* save_ptr; + char* str = strtok_r(mode, ",", &save_ptr); + do { + struct mode* mode_ptr = add_mode(str); + wl_list_insert(modes, &mode_ptr->link); + } while((str = strtok_r(NULL, ",", &save_ptr)) != NULL); + } else { + struct mode* mode_ptr = add_mode(mode); + wl_list_insert(modes, &mode_ptr->link); + } + gdk_threads_add_idle(insert_all_widgets, modes); + gtk_window_set_title(GTK_WINDOW(window), prompt); gtk_widget_show_all(window); }