simple notification daemon for wayland
Files | Log | Commits | Refs | README
Author: SM
Date: 2025-08-01
Subject: conf change
commit 5736601a28e8e30b1a3ff15b3add3879c688b946
Author: SM <seb.michalk@gmail.com>
Date: Fri Aug 1 23:00:03 2025 +0200
conf change
diff --git a/Makefile b/Makefile
index ccdbe35..ad6a4a7 100644
--- a/Makefile
+++ b/Makefile
@@ -68,4 +68,4 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/snot
rm -rf $(DESTDIR)$(PREFIX)/share/snot
-.PHONY: all clean install uninstall
\ No newline at end of file
+.PHONY: all clean install uninstall
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..cd2bb7c
--- /dev/null
+++ b/config.h
@@ -0,0 +1,29 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define NOTIFICATION_WIDTH NOTIFICATION_MIN_WIDTH
+#define NOTIFICATION_HEIGHT NOTIFICATION_MIN_HEIGHT
+
+/* appearance */
+#define BORDER_WIDTH 2
+#define PADDING 15
+#define BACKGROUND_COLOR "#222222" /* background color in hex */
+#define FOREGROUND_COLOR "#bbbbbb" /* text color in hex */
+#define BORDER_COLOR "#005577" /* border color in hex */
+#define FONT "Liberation Mono 10" /* font name and size */
+
+/* behavior */
+#define DURATION 3000 /* notification display duration in ms */
+#define FADE_TIME 200 /* fade animation duration in ms */
+#define MAX_NOTIFICATIONS 5 /* maximum number of notifications shown */
+#define SPACING 10 /* space between notifications */
+#define NOTIFICATION_MIN_WIDTH 300 /* minimum width */
+#define NOTIFICATION_MIN_HEIGHT 50 /* minimum height */
+#define NOTIFICATION_MAX_WIDTH 600 /* prevent notifications from getting too wide */
+
+/* position (0 = top, 1 = bottom) */
+#define POSITION 0
+/* alignment (0 = left, 1 = center, 2 = right) */
+#define ALIGNMENT 1
+
+#endif /* CONFIG_H */
diff --git a/config.mk b/config.mk
index 21aafdc..1e15569 100644
--- a/config.mk
+++ b/config.mk
@@ -3,10 +3,13 @@ VERSION = 0.1
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
-WLROOTS_DIR ?= $(shell pkg-config --variable=prefix wlroots 2>/dev/null)
-
PKG_CONFIG = pkg-config
+WLROOTS_PKG := $(shell ${PKG_CONFIG} --exists wlroots-0.18 && echo wlroots-0.18 || \
+ ${PKG_CONFIG} --exists wlroots-0.17 && echo wlroots-0.17 || \
+ ${PKG_CONFIG} --exists wlroots-0.16 && echo wlroots-0.16 || \
+ ${PKG_CONFIG} --exists wlroots && echo wlroots || echo none)
+
INCS = $(shell ${PKG_CONFIG} --cflags pixman-1) \
$(shell ${PKG_CONFIG} --cflags libdrm) \
$(shell ${PKG_CONFIG} --cflags pango) \
@@ -14,10 +17,10 @@ INCS = $(shell ${PKG_CONFIG} --cflags pixman-1) \
$(shell ${PKG_CONFIG} --cflags cairo) \
$(shell ${PKG_CONFIG} --cflags dbus-1)
-ifeq ($(WLROOTS_DIR),)
- INCS += $(shell ${PKG_CONFIG} --cflags wlroots)
+ifneq ($(WLROOTS_PKG),none)
+ INCS += $(shell ${PKG_CONFIG} --cflags $(WLROOTS_PKG))
else
- INCS += -I$(WLROOTS_DIR)/include
+ INCS += -I/usr/include/wlroots-0.18 -I/usr/include/wlroots -I/usr/local/include/wlroots
endif
LIBS = $(shell ${PKG_CONFIG} --libs wayland-client) \
@@ -25,14 +28,14 @@ LIBS = $(shell ${PKG_CONFIG} --libs wayland-client) \
$(shell ${PKG_CONFIG} --libs cairo) \
$(shell ${PKG_CONFIG} --libs dbus-1)
-ifeq ($(WLROOTS_DIR),)
- LIBS += $(shell ${PKG_CONFIG} --libs wlroots)
+ifneq ($(WLROOTS_PKG),none)
+ LIBS += $(shell ${PKG_CONFIG} --libs $(WLROOTS_PKG))
else
- LIBS += -L$(WLROOTS_DIR)/lib -lwlroots
+ LIBS += -lwlroots-0.18 -lwlroots
endif
CPPFLAGS = -D_DEFAULT_SOURCE
CFLAGS = -O2 -Wall ${INCS} ${CPPFLAGS}
LDFLAGS = ${LIBS}
-CC = gcc
\ No newline at end of file
+CC = gcc
diff --git a/dbus.c b/dbus.c
index fe8f452..680874f 100644
--- a/dbus.c
+++ b/dbus.c
@@ -44,9 +44,9 @@ static const char introspection_xml[] =
int
dbus_get_fd(void) {
- int fd;
- dbus_connection_get_unix_process_id(connection, &fd);
- return fd;
+ unsigned long pid;
+ dbus_connection_get_unix_process_id(connection, &pid);
+ return (int)pid;
}
static DBusHandlerResult
diff --git a/snot.c b/snot.c
index 997d6af..4e880c3 100644
--- a/snot.c
+++ b/snot.c
@@ -389,38 +389,6 @@ replace:
create_notification_surface(n);
}
-static void
-calculate_text_dimensions(cairo_t *cr, const char *summary, const char *body,
- int *width, int *height) {
- PangoLayout *layout = pango_cairo_create_layout(cr);
- PangoFontDescription *desc = pango_font_description_from_string(FONT);
- pango_layout_set_font_description(layout, desc);
-
- pango_layout_set_width(layout, (NOTIFICATION_WIDTH - 2 * PADDING) * PANGO_SCALE);
- pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
-
- int text_width, text_height;
- int total_height = 0;
- int max_width = 0;
-
- pango_layout_set_text(layout, summary, -1);
- pango_layout_get_pixel_size(layout, &text_width, &text_height);
- total_height = text_height;
- max_width = text_width;
-
- if (body) {
- pango_layout_set_text(layout, body, -1);
- pango_layout_get_pixel_size(layout, &text_width, &text_height);
- total_height += text_height + PADDING;
- max_width = MAX(max_width, text_width);
- }
-
- *width = max_width + (2 * PADDING);
- *height = total_height + (2 * PADDING);
-
- g_object_unref(layout);
- pango_font_description_free(desc);
-}
static void
remove_notification(int index) {