diff options
Diffstat (limited to 'src/dwminfo.c')
| -rw-r--r-- | src/dwminfo.c | 61 |
1 files changed, 61 insertions, 0 deletions
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 <stdio.h> +#include <unistd.h> + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xatom.h> + +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; +} |
