From b903602ff02f717469a0aa265a5167a97e91e52d Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Sat, 17 Aug 2024 17:36:04 +0700 Subject: done Xorg functions! Signed-off-by: fadhil riyanto --- init.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'init.c') diff --git a/init.c b/init.c index d880ad1..6feb970 100644 --- a/init.c +++ b/init.c @@ -35,6 +35,22 @@ struct xorg_data { Window root; }; +static void x_start(struct xorg_data *xorg_data) +{ + xorg_data->dpy = XOpenDisplay(NULL); + xorg_data->screen = DefaultScreen(xorg_data->dpy); + xorg_data->root = RootWindow(xorg_data->dpy, xorg_data->screen); +} + +static void xsetroot_summon(struct xorg_data *xorg_data, char* text) +{ + XStoreName(xorg_data->dpy, xorg_data->root, text); +} + +static void x_end(struct xorg_data *xorg_data) +{ + XCloseDisplay(xorg_data->dpy); +} void signal_handler(int signal) @@ -136,6 +152,9 @@ int main(int argc, char **argv, char *envp[]) { signal(SIGINT, signal_handler); struct gc_data gc; + struct xorg_data xorg_data; + + char randombuf[100]; @@ -150,7 +169,10 @@ int main(int argc, char **argv, char *envp[]) snprintf(randombuf, 100, "%s %s %s", time, battery, DESKTOP_NAME); - exec_xsetroot(&gc, envp, randombuf); + // exec_xsetroot(&gc, envp, randombuf); + x_start(&xorg_data); + xsetroot_summon(&xorg_data, randombuf); + x_end(&xorg_data); free(battery); free(time); @@ -160,5 +182,6 @@ int main(int argc, char **argv, char *envp[]) run_garbage_collector_clear(&gc); + return 0; } \ No newline at end of file -- cgit v1.2.3