Add possibility to use alternative path

This commit is contained in:
Isak Ellmer 2025-04-15 15:46:12 +02:00
parent fc69aa6e2b
commit 5fa012f9ad
4 changed files with 13 additions and 3 deletions

9
menu.c
View file

@ -26,6 +26,7 @@
struct menu *menu_create(menu_callback callback) {
struct menu *menu = calloc(1, sizeof(struct menu));
menu->strncmp = strncmp;
menu->path = NULL;
menu->font = "monospace 10";
menu->normalbg = 0x222222ff;
menu->normalfg = 0xbbbbbbff;
@ -86,10 +87,11 @@ static bool parse_color(const char *color, uint32_t *result) {
void menu_getopts(struct menu *menu, int argc, char *argv[]) {
const char *usage =
"Usage: wmenu [-biPv] [-f font] [-l lines] [-o output] [-p prompt]\n"
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n"
"\t[-d path]\n";
int opt;
while ((opt = getopt(argc, argv, "bhiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
while ((opt = getopt(argc, argv, "bhiPvf:l:o:p:N:n:M:m:S:s:d:")) != -1) {
switch (opt) {
case 'b':
menu->bottom = true;
@ -145,6 +147,9 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
fprintf(stderr, "Invalid selection foreground color: %s", optarg);
}
break;
case 'd':
menu->path = optarg;
break;
default:
fprintf(stderr, "%s", usage);
exit(EXIT_FAILURE);