commit 09b8e2741258df81efbedc7c74f9927196f4de6a
parent 6ac20376cadef5aadc4a456efbc58c3feb27544b
Author: Sweets <Sweets@users.noreply.github.com>
Date: Sat, 25 Apr 2020 22:46:58 -0700
tiramisoon
Diffstat:
3 files changed, 67 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
@@ -5,10 +5,10 @@ SRC := tiramisu.c callbacks.c
CFLAGS = -Wall
LDFLAGS = $(shell pkg-config --libs --cflags glib-2.0 gio-2.0)
-all: $(TARGET)
+all: clean $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(SRC) -o $(TARGET)
clean:
- $(RM) ./tiramisu
+ @[ -f ./tiramisu ] && $(RM) ./tiramisu
diff --git a/README.md b/README.md
@@ -0,0 +1,30 @@
+# Notifications, the UNIX way
+
+tiramisu is a notification daemon based on dunst that outputs notifications
+to STDOUT in order to allow the user to process notifications any way they prefer.
+
+Perhaps you want notifications to be sent to your bar? tiramisu allows you to do that.
+Maybe you want notifications to be redirected to your phone as push notifications? A little bit of elbow grease and some tiramisu would let you do that ;)
+
+# Usage
+
+Redirecting output of tiramisu to the input of another program is the ideal methodology to using
+tiramisu.
+
+```
+tiramisu | your-application
+```
+
+tiramisu outputs a new line for every relevant bit of information regarding a notification.
+Anywhere a string may be found in a notification a new-line may be placed,
+but the most likely scenario is that a new-line is only found in the notification body,
+and because this is the most likely scenario, the body is output last in the notification.
+
+# Configuration
+
+By default tiramisu opts out of outputting notification actions, replacement IDs,
+notification timeouts, and hints. These can be enabled by modifying `config.h`
+and uncommenting the needed functionality and recompiling tiramisu.
+
+Arrays are same-line, comma-separated. Associative arrays (dictionaries) are the same,
+except their keys prefix the values and are separated by a colon.
diff --git a/callbacks.c b/callbacks.c
@@ -9,11 +9,44 @@ void method_handler(GDBusConnection *connection, const gchar *sender,
GVariant *return_value = NULL;
if (!strcmp(method, "Notify")) {
- // ?
+ GVariantIter iterator;
+
+ void *value;
+
+ g_variant_iter_init(&iterator, parameters);
+
+ gchar *app_name;
+ g_variant_iter_next(&iterator, "s", &app_name);
+
+ guint32 replaces_id;
+ g_variant_iter_next(&iterator, "u", &replaces_id);
+
+ gchar *app_icon;
+ g_variant_iter_next(&iterator, "s", &app_icon);
+
+ gchar *summary;
+ g_variant_iter_next(&iterator, "s", &summary);
+
+ gchar *body;
+ g_variant_iter_next(&iterator, "s", &body);
+
+ GVariant *actions;
+ g_variant_iter_next(&iterator, "as", &actions);
+
+ GVariant *hints;
+ g_variant_iter_next(&iterator, "a{sv}", &hints);
+
+ gint32 timeout;
+ g_variant_iter_next(&iterator, "i", &timeout);
+
+ print("%s %d %s %s %s actions,hints %d",
+ app_name, replaces_id, app_icon, summary, body, timeout);
+
+ return_value = g_variant_new("(u)", 0);
+ goto flush;
}
if (!strcmp(method, "GetServerInformation")) {
- // ?
return_value = g_variant_new("(ssss)",
"tiramisu", "Sweets", "1.0", "1.2");
goto flush;