Handle missing XDG_RUNTIME_DIR explicitly

Also update the documentation to indicate that this is a Wayland thing
and not dwl-specific.
This commit is contained in:
Devin J. Pohly 2020-06-07 11:43:48 -05:00
parent f19d00b94a
commit 14063d58bb
2 changed files with 15 additions and 4 deletions

View file

@ -74,16 +74,20 @@ this process a SIGTERM and wait for it to terminate (if it hasn't already).
This makes it ideal not only for initialization but also for execing into a This makes it ideal not only for initialization but also for execing into a
user-level service manager like s6 or `systemd --user`. user-level service manager like s6 or `systemd --user`.
You'll have to explicitly set `XDG_RUNTIME_DIR` if your system doesn't do it for
you, e.g. `export XDG_RUNTIME_DIR=/tmp/xdg-runtime-$USER && mkdir -p
$XDG_RUNTIME_DIR`.
More/less verbose output can be requested with flags as well: More/less verbose output can be requested with flags as well:
* `-q`: quiet (log level WLR_SILENT) * `-q`: quiet (log level WLR_SILENT)
* `-v`: verbose (log level WLR_INFO) * `-v`: verbose (log level WLR_INFO)
* `-d`: debug (log level WLR_DEBUG) * `-d`: debug (log level WLR_DEBUG)
Note: Wayland requires a valid `XDG_RUNTIME_DIR`, which is usually set up by a
session manager such as `elogind` or `systemd-logind`. If your system doesn't
do this automatically, you will need to configure it prior to launching `dwl`,
e.g.:
export XDG_RUNTIME_DIR=/run/user/$(id -u)
mkdir -p $XDG_RUNTIME_DIR
## Known limitations and issues ## Known limitations and issues

7
dwl.c
View file

@ -1527,6 +1527,13 @@ main(int argc, char *argv[])
goto usage; goto usage;
wlr_log_init(loglevel, NULL); wlr_log_init(loglevel, NULL);
// Wayland requires XDG_RUNTIME_DIR for creating its communications
// socket
if (!getenv("XDG_RUNTIME_DIR")) {
fprintf(stderr, "XDG_RUNTIME_DIR must be set\n");
exit(EXIT_FAILURE);
}
/* The Wayland display is managed by libwayland. It handles accepting /* The Wayland display is managed by libwayland. It handles accepting
* clients from the Unix socket, manging Wayland globals, and so on. */ * clients from the Unix socket, manging Wayland globals, and so on. */
dpy = wl_display_create(); dpy = wl_display_create();