From cd93891efa5c8278f0ac3bb7abb3aa0d6d5f5aa6 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 28 Dec 2025 18:17:24 +0900 Subject: [PATCH] fix --- mpanel/launcher/module.c | 27 +++++++++++++++++++ mpanel/launcher/stb_ds.c | 2 ++ mpanel/startbutton/module.c | 52 +++---------------------------------- 3 files changed, 33 insertions(+), 48 deletions(-) create mode 100644 mpanel/launcher/stb_ds.c diff --git a/mpanel/launcher/module.c b/mpanel/launcher/module.c index c21ac4c..6a1cdc5 100644 --- a/mpanel/launcher/module.c +++ b/mpanel/launcher/module.c @@ -2,6 +2,12 @@ #include #include +#include + +#include +#include +#include + static int calc_gap(MwWidget box) { return MwGetInteger(box, MwNheight) - 18 * 2; } @@ -23,6 +29,21 @@ static int calc_size(MwWidget box, xl_node_t* node) { return (gap + 18) * ((c + (c % 2)) / 2) - gap; } +static void exec_button(MwWidget handle, void* user, void* client){ + char** args = MDEStringToExec(MwGetText(handle, "Sexec"), NULL); + int i; + + if(fork() == 0){ + execvp(args[0], args); + _exit(-1); + } + + for(i = 0; i < arrlen(args); i++) { + if(args[i] != NULL) free(args[i]); + } + arrfree(args); +} + void module_reload(MwWidget box, MwWidget user, xl_node_t* node) { int w = calc_size(box, node); int gap = calc_gap(box); @@ -82,6 +103,12 @@ void module_reload(MwWidget box, MwWidget user, xl_node_t* node) { MwNpixmap, px, NULL); + MwVaApply(btn, + "Sexec", n->text, + NULL); + + MwAddUserHandler(btn, MwNactivateHandler, exec_button, NULL); + c++; } diff --git a/mpanel/launcher/stb_ds.c b/mpanel/launcher/stb_ds.c new file mode 100644 index 0000000..689615c --- /dev/null +++ b/mpanel/launcher/stb_ds.c @@ -0,0 +1,2 @@ +#define STB_DS_IMPLEMENTATION +#include diff --git a/mpanel/startbutton/module.c b/mpanel/startbutton/module.c index a07b31f..d19a1cd 100644 --- a/mpanel/startbutton/module.c +++ b/mpanel/startbutton/module.c @@ -1,13 +1,13 @@ #include "config.h" -#include -#include - #define _MILSKO #include #include #include + #include +#include +#include #include #include @@ -172,57 +172,13 @@ static void call(const char* name, int dir, int symlink, void* user) { } } -static char** desktop_exec(const char* exec, const char* file) { - char** a = NULL; - int i; - char* buf = malloc(1); - - buf[0] = 0; - - for(i = 0;; i++) { - if(exec[i] == ' ' || exec[i] == 0) { - if(strlen(buf) > 0) arrput(a, buf); - - buf = malloc(1); - buf[0] = 0; - - if(exec[i] == 0) break; - } else if(exec[i] == '%') { - char c = exec[++i]; - - if(c == 'f' && file != NULL) { - char* old = buf; - - buf = malloc(strlen(old) + strlen(file) + 1); - strcpy(buf, old); - strcpy(buf + strlen(old), file); - - free(old); - } - } else { - char* old = buf; - - buf = malloc(strlen(old) + 2); - strcpy(buf, old); - buf[strlen(old)] = exec[i]; - buf[strlen(old) + 1] = 0; - - free(old); - } - } - - arrput(a, NULL); - - return a; -} - static void menu(MwWidget handle, void* user, void* client) { opaque_t* opaque = handle->opaque; char* s = NULL; MwMenu m = client; if(m->opaque != NULL) { - char** args = desktop_exec(m->opaque, NULL); + char** args = MDEStringToExec(m->opaque, NULL); int i; if(fork() == 0) {