summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wolff <janw@mailbox.org>2019-07-16 14:20:06 +0200
committerJan Wolff <janw@mailbox.org>2019-07-16 14:20:06 +0200
commit345e6e7d5495f67500c9ddb81d4bc789ee3e471e (patch)
tree05b50e9744307b0d56dc0e64a8779c65bdcb9bdf
parent85a60d03bbd4d09c54d4160e3fb2adbf1e6f505a (diff)
bugfix, don't keep connection to X open
-rw-r--r--.gitattributes2
-rw-r--r--Makefile2
-rw-r--r--dwmstatus.c27
3 files changed, 17 insertions, 14 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..5966153
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+.gitattributes export-ignore
+.gitignore export-ignore
diff --git a/Makefile b/Makefile
index 092b5a6..9ace516 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = 0.1.1
+VERSION = 0.1.2
CC = gcc
CFLAGS = -std=c11 -Wall -Wextra -DVERSION=\"${VERSION}\"
diff --git a/dwmstatus.c b/dwmstatus.c
index 2bdaa62..b658e1b 100644
--- a/dwmstatus.c
+++ b/dwmstatus.c
@@ -12,24 +12,30 @@
static char status[STATUS_SIZE];
static char status_tmp[STATUS_TMP_SIZE];
-static Display * dpy;
-static int screen;
-static Window root;
+void error(const char * err) {
+ fputs(err, stderr);
+ exit(EXIT_FAILURE);
+}
void print() {
#ifdef DEBUG
puts(status);
#else
+ Display * dpy;
+ int screen;
+ Window root;
+
+ if((dpy = XOpenDisplay(NULL)) == NULL)
+ error("failed to open X display");
+ screen = DefaultScreen(dpy);
+ root = RootWindow(dpy, screen);
+
XStoreName(dpy, root, status);
XFlush(dpy);
+ XCloseDisplay(dpy);
#endif
}
-void error(const char * err) {
- fputs(err, stderr);
- exit(EXIT_FAILURE);
-}
-
void update_tag(char * dst) {
strncpy(dst, TAG, BLOCK_SIZE);
}
@@ -105,11 +111,6 @@ int main(int argc, char * argv[]) {
else if(strcmp(argv[i], "--version") == 0) print_version();
}
- if((dpy = XOpenDisplay(NULL)) == NULL)
- error("failed to open X display");
- screen = DefaultScreen(dpy);
- root = RootWindow(dpy, screen);
-
while(1) {
update();
print();