This commit is contained in:
Nishi 2025-12-28 18:17:24 +09:00
commit cd93891efa
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 33 additions and 48 deletions

View file

@ -2,6 +2,12 @@
#include <Mw/Milsko.h>
#include <xemil.h>
#include <stb_ds.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
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++;
}

2
mpanel/launcher/stb_ds.c Normal file
View file

@ -0,0 +1,2 @@
#define STB_DS_IMPLEMENTATION
#include <stb_ds.h>