From 4e24d62b0f928cc9d5c8ba95ec973385257e59b9 Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Sat, 17 Aug 2024 17:22:13 +0700 Subject: test execve Signed-off-by: fadhil riyanto --- init.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/init.c b/init.c index 91856a0..29d232b 100644 --- a/init.c +++ b/init.c @@ -119,21 +119,32 @@ static void exec_xsetroot(struct gc_data *gc, char** envp, char* text) execve(XSETROOT_PATH, args, envp); } - int main(int argc, char **argv, char *envp[]) { signal(SIGINT, signal_handler); struct gc_data gc; + char randombuf[100]; + setup_fd(&gc); - // while (!need_exit) { - // get_bat_num(&gc); - // char* cropped = newline_cut(gc.bat0bufptr, &gc); + while (!need_exit) { + memset(randombuf, '\0', 100); + + get_bat_num(&gc); + char* battery = newline_cut(gc.bat0bufptr, &gc); + char* time = newline_cut(get_time(), &gc); + + snprintf(randombuf, 100, "%s %s %s", time, battery, DESKTOP_NAME); - // free(cropped); - // } - exec_xsetroot(&gc, envp, "tes aaa st"); + exec_xsetroot(&gc, envp, randombuf); + + free(battery); + free(time); + + sleep(1); + } + run_garbage_collector_clear(&gc); return 0; -- cgit v1.2.3