#include <stdio.h>
 #include <stdlib.h>
+#include <libgen.h>
 #include <X11/Xcursor/Xcursor.h>
 #include <X11/extensions/XInput2.h>
 #include <assert.h>
        Cursor cursor;
 
        if (argc < 3 || argc > 4) {
-               printf("usage: xicursor <ptrid> <shape> [<theme>]\n");
+               printf("usage: %s <ptrid> <shape> [<theme>]\n",
+                               basename(argv[0]));
                return 1;
        }
 
        }
 
 
-       if (argc == 4)
+       if (argc == 4) {
                theme = argv[3];
-       else
+       } else {
                theme = XcursorGetTheme(dpy);
                if (theme == NULL) {
                        fprintf(stderr, "Can't get cursor theme.\n");
                        return EXIT_FAILURE;
                }
+       }
 
        image = XcursorShapeLoadImage(shape, theme, size);
        if (image == NULL) {