on failure use error status code - seturgent - set urgency hints for X applications
 (HTM) git clone git://git.codemadness.org/seturgent
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit b17caf6ce32d347bede7f589cfdb892e3de5633a
 (DIR) parent 6700e19d19994f1c6926ff5ce246f3d54496bd22
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat, 13 May 2017 13:52:33 +0200
       
       on failure use error status code
       
       Diffstat:
         M seturgent.c                         |      17 +++++++++++------
       
       1 file changed, 11 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/seturgent.c b/seturgent.c
       @@ -12,37 +12,42 @@ die(const char *s) {
                exit(EXIT_FAILURE);
        }
        
       -static void
       +static int
        seturgency(Display *dpy, Window winid, Bool set) {
       +        int ret = EXIT_SUCCESS;
                XWMHints *hints = XGetWMHints(dpy, winid);
                if(!hints) {
                        fputs("seturgent: unable to get window manager hints.\n", stderr);
       -                return;
       +                return EXIT_FAILURE;
                }
                if(set)
                        hints->flags |= XUrgencyHint;
                else
                        hints->flags &= ~XUrgencyHint;
       -        if(!XSetWMHints(dpy, winid, hints))
       +        if(!XSetWMHints(dpy, winid, hints)) {
                        fputs("seturgent: unable to set urgency hint.\n", stderr);
       +                ret = EXIT_FAILURE;
       +        }
                XFree(hints);
       +        return ret;
        }
        
        int
        main(int argc, char **argv) {
                Display *dpy;
       +        int ret = EXIT_SUCCESS;
        
                if(argc < 2 || !strcmp(argv[1], "-h")) /* help / usage */
                        die("Usage: seturgent <winid> [0|1]\n");
                if(argc == 2 && !strcmp(argv[1], "-v")) /* version */
       -                die("seturgent-"VERSION" © 2010-2012 seturgent engineer, see " \
       +                die("seturgent-"VERSION" © 2010-2017 seturgent engineer, see " \
                            "LICENSE file for details.\n");
                if(!(dpy = XOpenDisplay(NULL)))
                        die("seturgent: unable to open display.\n");
                /* set the urgency hint (or not), if not specified its True. */
       -        seturgency(dpy, (Window)strtol(argv[1], NULL, 0),
       +        ret = seturgency(dpy, (Window)strtol(argv[1], NULL, 0),
                           !((argc > 2) && !atol(argv[2])));
                XSync(dpy, False);
                XCloseDisplay(dpy);
       -        return EXIT_SUCCESS;
       +        return ret;
        }