diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2014-10-25 21:54:14 +0300 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2014-10-25 21:54:14 +0300 |
commit | 2294ff46e57a2347f4753b0d09f7b5670b2d3c81 (patch) | |
tree | c338cd1bd5ee6d398cd4a40907f5589c3a3513ec | |
parent | ba03036a390c6dbcd18dbb7924ca844e54b5c3b8 (diff) | |
download | bemenu-2294ff46e57a2347f4753b0d09f7b5670b2d3c81.tar.gz bemenu-2294ff46e57a2347f4753b0d09f7b5670b2d3c81.tar.bz2 bemenu-2294ff46e57a2347f4753b0d09f7b5670b2d3c81.zip |
Remove duplicates.
-rw-r--r-- | client/bemenu-run.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/client/bemenu-run.c b/client/bemenu-run.c index 3ffb28d..0df48d5 100644 --- a/client/bemenu-run.c +++ b/client/bemenu-run.c @@ -121,6 +121,15 @@ read_items_to_menu_from_dir(struct bm_menu *menu, const char *path) uint32_t count; struct bm_item **items = bm_menu_get_items(menu, &count); qsort(items, count, sizeof(struct bm_item*), compare); + + bool unique = true; + for (uint32_t i = 0; i + 1 < count; i += unique) { + if (!(unique = strcmp(bm_item_get_text(items[i]), bm_item_get_text(items[i + 1])))) { + bm_item_free(items[i]); + bm_menu_remove_item_at(menu, i); + items = bm_menu_get_items(menu, &count); + } + } } static void |