File: ipc-addr.c

package info (click to toggle)
kanshi 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 244 kB
  • sloc: ansic: 1,648; xml: 493; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

#include "ipc.h"

int get_ipc_path(char *path, 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(path, size, "%s/fr.emersion.kanshi.%s", xdg_runtime_dir, wayland_display);
}