From b907912f3eddef1878f39bd13df13831e4f6bb26 Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Sat, 17 Aug 2024 13:57:25 +0700 Subject: test notify send Signed-off-by: fadhil riyanto --- init.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/init.c b/init.c index 6fae895..fe2483e 100644 --- a/init.c +++ b/init.c @@ -98,6 +98,31 @@ static void get_bat_num(struct gc_data *gc) read(*gc->openfd, gc->bat0bufptr, gc->file_sz); } +static void exec(struct gc_data *gc, char* bat0) +{ + int len = 2 + 1 + gc->file_sz; + + char* snprintfbuf = (char*)malloc(len); + memset(snprintfbuf, '\0', len); + + snprintf(snprintfbuf, len, "%s", bat0); + + char* args[] = { + NOTIFY_SEND_PATH, snprintfbuf, NULL + }; + + char *env[] = { + "DISPLAY=:0.0", + "DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-YY3FKxW0FU", + "guid=89e1272fd6c1e0b8c15834a666c048cc", + "DBUS_SESSION_BUS_PID=68930", NULL + }; + + execve(NOTIFY_SEND_PATH, args, env); + + free(snprintfbuf); +} + int main(void) { @@ -106,10 +131,13 @@ int main(void) setup_fd(&gc); - get_bat_num(&gc); - char* cropped = newline_cut(gc.bat0bufptr, &gc); - printf("%s", cropped); - free(cropped); + // while (!need_exit) { + // get_bat_num(&gc); + // char* cropped = newline_cut(gc.bat0bufptr, &gc); + + // free(cropped); + // } + exec(&gc, "test test test"); run_garbage_collector_clear(&gc); return 0; -- cgit v1.2.3