wmenu/wmenu.c

29 lines
530 B
C
Raw Normal View History

2022-01-16 08:32:58 -05:00
#define _POSIX_C_SOURCE 200809L
2024-05-02 18:45:49 -04:00
#include <string.h>
#include "menu.h"
2024-05-02 17:03:07 -04:00
#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));
2022-01-16 08:32:58 -05:00
}
}
int main(int argc, char *argv[]) {
struct menu *menu = menu_create();
menu_getopts(menu, argc, argv);
2024-05-02 17:03:07 -04:00
if (!menu->passwd) {
read_items(menu);
2022-01-16 08:32:58 -05:00
}
2024-05-02 18:45:49 -04:00
int status = menu_run(menu);
menu_destroy(menu);
return status;
2022-01-16 08:32:58 -05:00
}