mirror of
https://github.com/emersion/kanshi
synced 2024-09-19 10:21:35 +02:00
afab6397ed
We don't want to fallback to libwayland's defaults, so WAYLAND_DISPLAY needs to be set in env. Since IPC in the future is going to use XDG_RUNTIME_DIR, we also require it. Because these functions will be used in other parts of the code as well, we rework the build system slightly to accommodate it. Co-authored-by: Érico Nogueira <erico.erc@gmail.com>
22 lines
592 B
C
22 lines
592 B
C
#define _POSIX_C_SOURCE 200809L
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "ipc.h"
|
|
|
|
int get_ipc_address(char *address, size_t size) {
|
|
const char *wayland_display = getenv("WAYLAND_DISPLAY");
|
|
const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
|
|
if (!wayland_display || !wayland_display[0]) {
|
|
fprintf(stderr, "WAYLAND_DISPLAY is not set\n");
|
|
return -1;
|
|
}
|
|
if (!xdg_runtime_dir || !xdg_runtime_dir[0]) {
|
|
fprintf(stderr, "XDG_RUNTIME_DIR is not set\n");
|
|
return -1;
|
|
}
|
|
|
|
return snprintf(address, size, "unix:%s/fr.emersion.kanshi.%s",
|
|
xdg_runtime_dir, wayland_display);
|
|
}
|