summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorfadhil riyanto <me@fadev.org>2024-08-17 17:22:13 +0700
committerfadhil riyanto <me@fadev.org>2024-08-17 17:22:13 +0700
commit4e24d62b0f928cc9d5c8ba95ec973385257e59b9 (patch)
treea27d80e9c5b70f56926ed9b5b6ffc511b7a8beaf /init.c
parentfcc81c7f8e6efab177a55238188f5ea1e3db7734 (diff)
test execve
Signed-off-by: fadhil riyanto <me@fadev.org>
Diffstat (limited to 'init.c')
-rw-r--r--init.c25
1 files 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;