diff options
author | Phil Jones <philj56@gmail.com> | 2022-11-20 10:27:23 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-11-20 10:27:23 +0000 |
commit | cd424929714021de0186d40154cbf56ff6b5d423 (patch) | |
tree | 3d679e9a3940e58b16f93f8e35f244b81d6fefc3 /src/main.c | |
parent | 17251c68d544b99308356c7d0a188a92e8aa194e (diff) |
Clean up drun launch logic a little bit.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -958,22 +958,26 @@ static bool do_submit(struct tofi *tofi) if (entry->drun) { /* - * TODO: This is ugly. The list of apps needs to be sorted - * alphabetically for bsearch to find the selected entry, but - * we previously sorted by history count. This needs fixing. + * At this point, the list of apps is history sorted rather + * than alphabetically sorted, so we can't use + * desktop_vec_find_sorted(). */ - desktop_vec_sort(&entry->apps); - struct desktop_entry *app = desktop_vec_find_sorted(&entry->apps, res); + struct desktop_entry *app = NULL; + for (size_t i = 0; i < entry->apps.count; i++) { + if (!strcmp(res, entry->apps.buf[i].name)) { + app = &entry->apps.buf[i]; + break; + } + } if (app == NULL) { log_error("Couldn't find application file! This shouldn't happen.\n"); return false; - } else { - res = app->path; } + char *path = app->path; if (tofi->drun_launch) { - drun_launch(res); + drun_launch(path); } else { - drun_print(res, tofi->default_terminal); + drun_print(path, tofi->default_terminal); } } else { printf("%s\n", res); |