From 1c6bc9f92dd225a3b7ed53cff158efceaf99eb6d Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 12 Jun 2023 17:09:34 +0200 Subject: [PATCH] Add -fl argument which can be used to check if a feature is supported This could be very useful for shell scripts, or debugging. --- docs/docs.md | 3 +++ libs/argv.c | 42 ++++++++++++++++++++++++++++++++++++++++++ libs/argv.h | 1 + spmenu.1 | 3 +++ 4 files changed, 49 insertions(+) diff --git a/docs/docs.md b/docs/docs.md index c8eb1a7..5bbbaf7 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -368,6 +368,9 @@ You may use long, descriptive arguments or the shorter arguments. `-rv, --raw-version` : Print raw spmenu version number to stdout +`-fl, --feature-list` +: List the state of all features that can be toggled + `-fn, --font font` : Set the spmenu font to font diff --git a/libs/argv.c b/libs/argv.c index 7d52dc1..70722af 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -89,6 +89,9 @@ void readargs(int argc, char *argv[]) { if (!strcmp(argv[i], "-v") || (!strcmp(argv[i], "--version"))) { // prints version information puts("spmenu-"VERSION); exit(0); + } else if (!strcmp(argv[i], "-fl") || (!strcmp(argv[i], "--feature-list"))) { // feature list + comp_opts(); + exit(0); } else if (!strcmp(argv[i], "-rv") || (!strcmp(argv[i], "--raw-version"))) { // help puts(VERSION); exit(0); @@ -524,6 +527,44 @@ void readargs(int argc, char *argv[]) { insert(input, strlen(input)); } +void comp_opts(void) { +#if USEWAYLAND + fprintf(stdout, "Wayland: Supported\n"); +#else + fprintf(stdout, "Wayland: Unsupported\n"); +#endif +#if USEX + fprintf(stdout, "X11: Supported\n"); +#else + fprintf(stdout, "X11: Unsupported\n"); +#endif +#if USERTL + fprintf(stdout, "RTL: Supported\n"); +#else + fprintf(stdout, "RTL: Unsupported\n"); +#endif +#if USEIMAGE + fprintf(stdout, "Images: Supported\n"); +#else + fprintf(stdout, "Images: Unsupported\n"); +#endif +#if USEXINERAMA + fprintf(stdout, "Xinerama: Supported\n"); +#else + fprintf(stdout, "Xinerama: Unsupported\n"); +#endif +#if USECONFIG + fprintf(stdout, "Config: Supported\n"); +#else + fprintf(stdout, "Config: Unsupported\n"); +#endif +#if USEXRESOURCES + fprintf(stdout, "xrdb: Supported\n"); +#else + fprintf(stdout, "xrdb: Unsupported\n"); +#endif +} + void usage(int status) { // print help fputs("spmenu ", status ? stderr : stdout); @@ -659,6 +700,7 @@ void usage(int status) { "spmenu -wl, --wayland Run spmenu in Wayland mode\n" "spmenu -rv, --raw-version Print spmenu version number to stdout\n" "spmenu -v, --version Print spmenu version to stdout\n" + "spmenu -fl, --feature-list List the state of all features that can be toggled\n" "\n", status ? stderr : stdout); // colors diff --git a/libs/argv.h b/libs/argv.h index cb23acd..306182b 100644 --- a/libs/argv.h +++ b/libs/argv.h @@ -1,3 +1,4 @@ /* See LICENSE file for copyright and license details. */ static void readargs(int argc, char *argv[]); static void usage(int status); +static void comp_opts(void); diff --git a/spmenu.1 b/spmenu.1 index 86ccbfa..e0992ff 100644 --- a/spmenu.1 +++ b/spmenu.1 @@ -396,6 +396,9 @@ Print spmenu version to stdout \f[V]-rv, --raw-version\f[R] Print raw spmenu version number to stdout .TP +\f[V]-fl, --feature-list\f[R] +List the state of all features that can be toggled +.TP \f[V]-fn, --font font\f[R] Set the spmenu font to font .TP