summaryrefslogtreecommitdiff
path: root/xbar.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-26 16:24:00 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-26 16:24:00 -0400
commitfc8f01587cafa361e97abc30234094859b262307 (patch)
tree6dca103e6ecfb36d63c14b4c7deaae0a3edd1499 /xbar.c
initial commit
Diffstat (limited to 'xbar.c')
-rw-r--r--xbar.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/xbar.c b/xbar.c
new file mode 100644
index 0000000..01090fa
--- /dev/null
+++ b/xbar.c
@@ -0,0 +1,55 @@
+/* MAJE_LDLIB=-lX11 */
+
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <X11/Xlib.h>
+
+int main(int argc, char *argv[])
+{
+ int c = 0;
+ while ((c = getopt(argc, argv, "")) != -1) {
+ switch (c) {
+ default:
+ return 1;
+ }
+ }
+
+ Display *dpy = XOpenDisplay("");
+ if (dpy == NULL) {
+ fprintf(stderr, "xbar: can't open display\n");
+ return 1;
+ }
+
+ int screen = DefaultScreen(dpy);
+ int width = DisplayWidth(dpy, screen);
+ int height = 20;
+
+ Window win = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy),
+ 0, 0, width, height, 0,
+ BlackPixel(dpy, screen), BlackPixel(dpy, screen));
+ XSelectInput(dpy, win, ExposureMask | KeyPressMask);
+ XMapWindow(dpy, win);
+
+ for (;;) {
+ XEvent e;
+ XNextEvent(dpy, &e);
+ switch (e.type) {
+ case Expose:
+ XDrawString(dpy, win, DefaultGC(dpy, screen), 0, 0,
+ "hello", strlen("hello"));
+ break;
+
+ case KeyPress:
+ printf("keypress\n");
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}