commit 0a60763749be1898ca7b3e90db94a7daf25ec6b6
parent fe3718617afcabf880b01445aa127f0cbce83936
Author: Janne Veteläinen <janne.vetelainen@elisanet.fi>
Date: Mon, 29 Apr 2024 18:47:02 +0300
Make subdir for systray
Diffstat:
10 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -9,8 +9,5 @@ xdg-output-unstable-v1-protocol.c
xdg-output-unstable-v1-protocol.h
dwl-ipc-unstable-v2-protocol.c
dwl-ipc-unstable-v2-protocol.h
-dwlbtray
-valgrind*
-pango.supp
.cache
compile_commands.json
diff --git a/Makefile b/Makefile
@@ -1,20 +1,22 @@
-BINS = dwlb dwlbtray
+BINS = dwlb
MANS = dwlb.1
PREFIX ?= /usr/local
CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-format-truncation -g
-all: $(BINS)
+all: $(BINS) systray
config.h:
cp config.def.h $@
clean:
$(RM) $(BINS) $(addsuffix .o,$(BINS))
+ $(MAKE) clean -C systray
install: all
install -D -t $(PREFIX)/bin $(BINS)
install -D -m0644 -t $(PREFIX)/share/man/man1 $(MANS)
+ $(MAKE) install -C systray
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
@@ -48,16 +50,12 @@ dwlb.o: utf8.h config.h xdg-shell-protocol.h xdg-output-unstable-v1-protocol.h w
# Protocol dependencies
dwlb: xdg-shell-protocol.o xdg-output-unstable-v1-protocol.o wlr-layer-shell-unstable-v1-protocol.o dwl-ipc-unstable-v2-protocol.o
-statusnotifierhost.o: dwlbtray.h
-statusnotifieritem.o: dwlbtray.h
-dbusmenu.o: dwlbtray.h
-dwlbtray.o: dwlbtray.h
-dwlbtray: dwlbtray.o statusnotifierhost.o statusnotifieritem.o dbusmenu.o
-
# Library dependencies
dwlb: CFLAGS+=$(shell pkg-config --cflags wayland-client wayland-cursor fcft pixman-1)
dwlb: LDLIBS+=$(shell pkg-config --libs wayland-client wayland-cursor fcft pixman-1) -lrt
-dwlbtray: CFLAGS+=$(shell pkg-config --cflags glib-2.0 gtk4 gtk4-layer-shell-0)
-dwlbtray: LDLIBS+=$(shell pkg-config --libs glib-2.0 gtk4 gtk4-layer-shell-0) -lrt
-.PHONY: all clean install
+systray:
+ $(MAKE) -C systray
+
+
+.PHONY: all systray clean install
diff --git a/dwlb.c b/dwlb.c
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <libgen.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/socket.h>
@@ -1691,6 +1692,7 @@ start_systray(const char *parent_progname, const char *traymon, bool bottom)
{
char tray_exe_path[PATH_MAX];
char traypath_maybe[PATH_MAX];
+ char progname_buf[PATH_MAX];
char traybg_arg[64];
char height_arg[64];
char traymon_arg[64];
@@ -1704,7 +1706,14 @@ start_systray(const char *parent_progname, const char *traymon, bool bottom)
(traybg_clr->green / 0x101),
(traybg_clr->blue) / 0x101);
- snprintf(traypath_maybe, sizeof(traypath_maybe), "%stray", parent_progname);
+ strncpy(progname_buf, parent_progname, sizeof(progname_buf));
+ char *lastslash = strrchr(progname_buf, '/');
+ if (lastslash) {
+ *(lastslash) = '\0';
+ snprintf(traypath_maybe, sizeof(traypath_maybe), "%s/systray/dwlbtray", progname_buf);
+ } else {
+ *(traypath_maybe) = '\0';
+ }
if (access(traypath_maybe, X_OK) == 0)
strcpy(tray_exe_path, traypath_maybe);
else
diff --git a/systray/.gitignore b/systray/.gitignore
@@ -0,0 +1,6 @@
+*.o
+dwlbtray
+valgrind*
+pango.supp
+.cache
+compile_commands.json
diff --git a/systray/Makefile b/systray/Makefile
@@ -0,0 +1,21 @@
+BINS = dwlbtray
+OBJS = statusnotifierhost.o statusnotifieritem.o dbusmenu.o dwlbtray.o
+
+PREFIX ?= /usr/local
+CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g
+
+all: $(BINS)
+
+clean:
+ $(RM) $(BINS) $(OBJS)
+
+install: all
+ install -D -t $(PREFIX)/bin $(BINS)
+
+%.o: dwlbtray.h
+dwlbtray: $(OBJS)
+
+dwlbtray: CFLAGS+=$(shell pkg-config --cflags glib-2.0 gtk4 gtk4-layer-shell-0)
+dwlbtray: LDLIBS+=$(shell pkg-config --libs glib-2.0 gtk4 gtk4-layer-shell-0) -lrt
+
+.PHONY: all clean install
diff --git a/dbusmenu.c b/systray/dbusmenu.c
diff --git a/dwlbtray.c b/systray/dwlbtray.c
diff --git a/dwlbtray.h b/systray/dwlbtray.h
diff --git a/statusnotifierhost.c b/systray/statusnotifierhost.c
diff --git a/statusnotifieritem.c b/systray/statusnotifieritem.c