commit 7c7bbaee4695ab7d91ef74b36ec63ac73d70881a from: Alexander Arkhipov date: Sat May 27 18:55:01 2023 UTC initial implementation of user options commit - 3dac010d3e678174cdff382641a67e8c1a99910b commit + 7c7bbaee4695ab7d91ef74b36ec63ac73d70881a blob - a7752b19fdd25c115a8c881e05abe65bbbcdbb22 blob + da97bfb0362e0b84d7c36faf7b4a88202a602860 --- xitems.c +++ xitems.c @@ -15,12 +15,21 @@ #define HPAD 2 /* horizontal padding */ #define VPAD 1 /* vertical padding */ +#define PROGNAME "xitems" + #define LEN(A) (sizeof(A)/sizeof((A)[0])) static void +usage(void) +{ + printf("too bad\n"); + exit(1); +} + +static void errx(int eval, const char *fmt, ...) { - fputs("lockscreen: ", stderr); + fputs(PROGNAME ": ", stderr); if (fmt) { va_list argp; va_start(argp, fmt); @@ -93,27 +102,153 @@ redraw(struct item *first, int height, int width, XFon } while (it != first); } +char * +sdefault(char *opt, char *def) +{ + char *val = XGetDefault(dpy, PROGNAME, opt); + return val ? val : def; +} + int +idefault(char *opt, int def) +{ + char *val = XGetDefault(dpy, PROGNAME, opt); + return val ? atoi(val) : def; +} + +char * +sarg(int *argcp, c