removed setstatus() && simplified main()
authorAli H. Fardan <raiz@firemail.cc>
Fri, 2 Sep 2016 19:13:58 +0000 (22:13 +0300)
committerAli H. Fardan <raiz@firemail.cc>
Fri, 2 Sep 2016 19:13:58 +0000 (22:13 +0300)
slstatus.c

index 368b51c512323a6d3336784be83596e9dd51c5c7..2e57fbb048ca791baf2fb83cb958d488bb06ccba 100644 (file)
@@ -33,7 +33,6 @@ struct arg {
        const char *args;
 };
 
-static void setstatus(const char *);
 static char *smprintf(const char *, ...);
 static char *battery_perc(const char *);
 static char *cpu_perc(void);
@@ -64,14 +63,6 @@ static Display *dpy;
 
 #include "config.h"
 
-static void
-setstatus(const char *str)
-{
-       /* set WM_NAME via X11 */
-       XStoreName(dpy, DefaultRootWindow(dpy), str);
-       XSync(dpy, False);
-}
-
 static char *
 smprintf(const char *fmt, ...)
 {
@@ -625,10 +616,6 @@ main(void)
        struct arg argument;
 
        dpy = XOpenDisplay(0x0);
-       if (!dpy) {
-               fprintf(stderr, "Cannot open display!\n");
-               exit(1);
-       }
 
        for (;;) {
                memset(status_string, 0, sizeof(status_string));
@@ -648,7 +635,8 @@ main(void)
                        free(element);
                }
 
-               setstatus(status_string);
+               XStoreName(dpy, DefaultRootWindow(dpy), status_string);
+               XSync(dpy, False);
                sleep(UPDATE_INTERVAL -1);
        }
 
@@ -657,8 +645,6 @@ main(void)
         * TODO: find out a way to exit successfully
         * to prevent memory leaks
         */
-/*
        XCloseDisplay(dpy);
        return 0;
-*/
 }