Add -fl argument which can be used to check if a feature is supported

This could be very useful for shell scripts, or debugging.
This commit is contained in:
speedie 2023-06-12 17:09:34 +02:00
parent 35d2f721a4
commit 1c6bc9f92d
4 changed files with 49 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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