diff options
| author | coasteen <coasteen@proton.me> | 2026-07-09 10:42:28 +0330 |
|---|---|---|
| committer | coasteen <coasteen@proton.me> | 2026-07-09 10:42:28 +0330 |
| commit | 8cbadb61604667b407b53ee1258433994fa4765a (patch) | |
| tree | 97765fb29418fd6278fcb4cbb9760893afaf7a58 /wmenu/wmenu.c | |
Diffstat (limited to 'wmenu/wmenu.c')
| -rwxr-xr-x | wmenu/wmenu.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/wmenu/wmenu.c b/wmenu/wmenu.c new file mode 100755 index 0000000..38e78b9 --- /dev/null +++ b/wmenu/wmenu.c @@ -0,0 +1,35 @@ +#define _POSIX_C_SOURCE 200809L + +#include <stdio.h> +#include <string.h> + +#include "menu.h" +#include "wayland.h" + +static void read_items(struct menu *menu) { + char buf[sizeof menu->input]; + while (fgets(buf, sizeof buf, stdin)) { + char *p = strchr(buf, '\n'); + if (p) { + *p = '\0'; + } + menu_add_item(menu, strdup(buf)); + } +} + +static void print_item(struct menu *menu, char *text, bool exit) { + puts(text); + fflush(stdout); + if (exit) { + menu->exit = true; + } +} + +int main(int argc, char *argv[]) { + struct menu *menu = menu_create(print_item); + menu_getopts(menu, argc, argv); + read_items(menu); + int status = menu_run(menu); + menu_destroy(menu); + return status; +} |
