tmisu

Notification to stdout daemon
git clone https://git.inz.fi/tmisu/
Log | Files | Refs | README | LICENSE

commit 727be20c7790b4bd6bd9072824c4a36db3e29841
parent 5966e3302168f768687337f2aaac007289156e34
Author: Sweets <Sweets@users.noreply.github.com>
Date:   Sat, 25 Apr 2020 15:22:10 -0700

Rename

Diffstat:
MMakefile | 6+++---
Mcallbacks.c | 2+-
Anote | 0
Atiramisu.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atiramisu.h | 9+++++++++
5 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,6 +1,6 @@ -TARGET = note -SRC := note.c callbacks.c +TARGET = tiramisu +SRC := tiramisu.c callbacks.c CFLAGS = -Wall LDFLAGS = $(shell pkg-config --libs --cflags glib-2.0 gio-2.0) @@ -11,4 +11,4 @@ $(TARGET): $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) $(SRC) -o $(TARGET) clean: - $(RM) ./note + $(RM) ./tiramisu diff --git a/callbacks.c b/callbacks.c @@ -1,4 +1,4 @@ -#include "note.h" +#include "tiramisu.h" #include "callbacks.h" void notification_received(GDBusConnection *connection, const gchar *sender, diff --git a/note b/note Binary files differ. diff --git a/tiramisu.c b/tiramisu.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <string.h> + +#include <gio/gio.h> +#include <glib.h> + +#include "tiramisu.h" +#include "callbacks.h" +#include "config.h" + +GDBusConnection *dbus_connection = NULL; + +/* Build introspection XML based on configuration */ + +const char *introspection = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<node name=\"/org/freedesktop/Notifications\">\n" + " <interface name=\"org.freedesktop.Notifications\">\n" + " <method name=\"Notify\">\n" +#ifdef RECEIVE_ACTIONS + " <arg direction=\"in\" name=\"actions\" type=\"as\"/>\n" +#endif +#ifdef RECEIVE_APP_ICON + " <arg direction=\"in\" name=\"app_icon\" type=\"s\"/>\n" +#endif + " <arg direction=\"in\" name=\"app_name\" type=\"s\"/>\n" + " <arg direction=\"in\" name=\"body\" type=\"s\"/>\n" +#ifdef RECEIVE_EXPIRE_TIMEOUT + " <arg direction=\"in\" name=\"expire_timeout\" type=\"i\"/>\n" +#endif + " <arg direction=\"in\" name=\"hint\" type=\"a{sv}\"/>\n" + " <arg direction=\"in\" name=\"id\" type=\"u\"/>\n" +#ifdef RECEIVE_REPLACES_ID + " <arg direction=\"in\" name=\"replaces_id\" type=\"u\"/>\n" +#endif + " <arg direction=\"in\" name=\"summary\" type=\"s\"/>\n" + " </method>\n" + " </interface>\n" + "</node>"; + +int main(int argc, char **argv) { + GMainLoop *main_loop; + + guint owned_name; + GDBusNodeInfo *introspection_data; + + /* Connect to DBUS */ + + introspection_data = g_dbus_node_info_new_for_xml(introspection, NULL); + owned_name = g_bus_own_name(G_BUS_TYPE_SESSION, + "org.freedesktop.Notifications", + G_BUS_NAME_OWNER_FLAGS_NONE, + (GBusAcquiredCallback)bus_acquired, /* bus_acquired_handler */ + (GBusNameAcquiredCallback)name_acquired, /* name_acquired_handler */ + (GBusNameLostCallback)name_lost, /* name_lost_handler */ + NULL, /* user_data */ + NULL); /* user_data_free_func */ + + /* Setup and start the loop */ + + main_loop = g_main_loop_new(NULL, FALSE); + + g_main_loop_run(main_loop); + g_clear_pointer(&main_loop, g_main_loop_unref); + + g_clear_pointer(&introspection_data, g_dbus_node_info_unref); + g_bus_unown_name(owned_name); + +} diff --git a/tiramisu.h b/tiramisu.h @@ -0,0 +1,9 @@ +#pragma once + +#include <stdio.h> +#include <string.h> + +#include <gio/gio.h> +#include <glib.h> + +extern GDBusConnection *dbus_connection;