Commit 65b9f738 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

Merge branch 'wip/human-version' into 'master'

Add human-readable output

See merge request !1
parents 126c4be0 080a9601
Pipeline #147966 passed with stages
in 35 seconds
.TH "xisxwayland" "1"
.SH "NAME"
xisxwayland \- tool to be used within shell scripts to determine whether the
X server in use is Xwayland
xisxwayland \- tool to be used within shell scripts to check for Xwayland
.
.SH "SYNOPSIS"
.B xisxwayland
.B xisxwayland [\-v|\-\-verbose]
.
.SH "DESCRIPTION"
Connects to the X server using the
Connects to the X server using the
.B $DISPLAY
environment variable and checks whether that server is an Xwayland server or
not.
environment variable and checks whether that server is an Xwayland server.
.SH "OPTIONS"
.TP 8
.B \-\-verbose, \-v
Print to stdout whether the X server is an Xwayland server or not
.
.SH "EXIT STATUS"
.B xisxwayland
......
......@@ -21,6 +21,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -35,15 +36,16 @@
static void usage(void)
{
fprintf(stderr,
"Usage: xisxwayland\n"
"Usage: xisxwayland [-v|--verbose]\n"
"\n"
"Options:\n"
" -v, --verbose ... verbose output\n"
"\n"
"Exit status:\n"
" 0 ... the X server is Xwayland\n"
" 1 ... the X server is not Xwayland\n"
" 2 ... invalid usage\n"
" 3 ... failed to connect to the X server\n"
"\n"
"This tool does not take any options or arguments\n");
" 3 ... failed to connect to the X server\n");
exit(EXIT_INVALID_USAGE);
}
......@@ -53,9 +55,15 @@ int xisxwayland(int argc, char **argv __attribute__((unused)))
XRRScreenResources *resources = NULL;
XRROutputInfo *output = NULL;
int rc = EXIT_ERROR;
bool verbose = false;
if (argc > 1)
usage();
if (argc > 1) {
if (argc == 2)
verbose = strcmp(argv[1], "-v") == 0 ||
strcmp(argv[1], "--verbose") == 0;
if (!verbose)
usage();
}
dpy = XOpenDisplay(NULL);
if (!dpy) {
......@@ -106,5 +114,18 @@ out:
if (dpy)
XCloseDisplay(dpy);
if (verbose) {
switch (rc) {
case EXIT_IS_XWAYLAND:
printf("Xwayland: YES\n");
break;
case EXIT_NOT_XWAYLAND:
printf("Xwayland: NO\n");
break;
default:
break;
}
}
return rc;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment