Re: [hackers] [xssstate] Refactor xssstate.c

2016-09-11 Thread Russ
> does it really simplify the code? I think it makes it less readable
> without arg.h.
 
I agree it does some, but using strcmp allows matching the flags exactly, and 
prevents things like "xssstate -v" being equivilant to "xssstate -vxyz".  And 
since you would only ever use one flag at a time, arg.h seemed like it was 
excessive, but perhaps I was thinking about simplify the wrong way.  I also like
being able to use only one switch statement,  but that's mostly a personal 
preference.  Thanks for the input!

Russ



[hackers] [xssstate] Refactor xssstate.c

2016-09-11 Thread Russ
e("Screensaver extension not activated.\n");
-
-   info = XScreenSaverAllocInfo();
-   XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
-
-   if (showstate) {
-   switch(info->state) {
-   case ScreenSaverOn:
-   printf("on\n");
-   break;
-   case ScreenSaverOff:
-   printf("off\n");
-   break;
-   case ScreenSaverDisabled:
-   printf("disabled\n");
-   break;
-   }
-   } else if (showtill) {
-   switch(info->state) {
+   die("xssstate: screensaver extension not available");
+   if (!(info = XScreenSaverAllocInfo()))
+   die("xssstate: insufficient memory available");
+   if (!XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info))
+   die("xssstate: screensaver extension not supported");
+   if (idle) {
+   printf("%lu\n", info->idle);
+   } else {
+   switch (info->state) {
case ScreenSaverOn:
-   printf("0\n");
+   state ? printf("on\n") : printf("0\n");
break;
case ScreenSaverOff:
-   printf("%lu\n", info->til_or_since);
-   break;
-   case ScreenSaverDisabled:
-   printf("-1\n");
+   state ? printf("off\n") :
+   printf("%lu\n", info->til_or_since);
break;
+   default:
+   state ? printf("disabled\n") : printf("-1\n");
}
-   } else if (showidle) {
-   printf("%lu\n", info->idle);
}
-
-
XCloseDisplay(dpy);
+   XFree(info);
 
return 0;
 }
-
___

Russ



[hackers] st scrollback patch dead link

2015-12-19 Thread Russ Roissier, Jr.
The link for "st-git-20151122-scrollback.diff" returns

The requested document at
'*http://st.suckless.org/patches/st-git-20151217-scrollback.diff
*' doesn't
exist