From d9b456d738e5013d48f41f5e6315ef7c22d6acf0 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Sep 2025 19:37:28 +0100 Subject: Initial commit --- src/dwminfo.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/dwminfo.c (limited to 'src/dwminfo.c') diff --git a/src/dwminfo.c b/src/dwminfo.c new file mode 100644 index 0000000..8e04b43 --- /dev/null +++ b/src/dwminfo.c @@ -0,0 +1,61 @@ +#include "signal.h" +#include "text.h" + +#include +#include + +#include +#include +#include + +struct state { + Display * display; + Window window; + struct text * text; +}; + +static int +init_state(struct state * s) +{ + s->display = XOpenDisplay(NULL); + s->window = XDefaultRootWindow(s->display); + s->text = text_new(); + return 0; +} + +static void +deinit_state(struct state * s) +{ + XCloseDisplay(s->display); + text_free(s->text); +} + +static void +update_status(struct state * s) +{ + text_update(s->text); + XStoreName(s->display, s->window, s->text->value); + XSync(s->display, 1); +} + +static void +run_loop(struct state * s) +{ + while(signal_running) { + update_status(s); + usleep(1000 * 500); + } +} + +int main(void) +{ + struct state s; + + signal_setup_actions(); + + init_state(&s); + run_loop(&s); + deinit_state(&s); + + return 0; +} -- cgit v1.2.3