From 86c917fc952317295563027784207bbebc915c7d Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Fri, 20 Jan 2017 19:26:16 +0200 Subject: [PATCH] Implement raw icon support for dunstify Add the ability to send raw icons with dunstify -I . --- Makefile | 7 ++++--- dunstify.c | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9e6d6a5..7f136cb 100644 --- a/Makefile +++ b/Makefile @@ -37,15 +37,13 @@ dunst: options ${OBJ} main.o @echo "${CC} ${CFLAGS} -o $@ ${OBJ} ${LDFLAGS}" @${CC} ${CFLAGS} -o $@ ${OBJ} main.o ${LDFLAGS} -dunstify: - @${CC} ${CFLAGS} -o $@ dunstify.c -std=c99 $(shell pkg-config --libs --cflags glib-2.0 libnotify) - clean-dunst: rm -f dunst ${OBJ} main.o rm -f org.knopwob.dunst.service rm -f dunst.systemd.service clean-dunstify: + rm -f dunstify.o rm -f dunstify clean-doc: @@ -104,4 +102,7 @@ test/test: ${OBJ} ${TEST_OBJ} test-clean: rm -f test/test test/*.o +dunstify: dunstify.o + ${CC} ${CFLAGS} -o $@ dunstify.o $(shell pkg-config --libs --cflags glib-2.0 libnotify gdk-2.0) + .PHONY: all options clean dist install uninstall diff --git a/dunstify.c b/dunstify.c index 6ae1788..dd8fcfc 100644 --- a/dunstify.c +++ b/dunstify.c @@ -3,6 +3,7 @@ #include #include #include +#include static gchar *appname = "dunstify"; static gchar *summary = NULL; @@ -13,6 +14,7 @@ static gchar **hint_strs = NULL; static gchar **action_strs = NULL; static gint timeout = NOTIFY_EXPIRES_DEFAULT; static gchar *icon = NULL; +static gchar *raw_icon_path = NULL; static gboolean capabilities = false; static gboolean serverinfo = false; static gboolean printid = false; @@ -28,6 +30,7 @@ static GOptionEntry entries[] = { "action", 'A', 0, G_OPTION_ARG_STRING_ARRAY, &action_strs, "Actions the user can invoke", "ACTION" }, { "timeout", 't', 0, G_OPTION_ARG_INT, &timeout, "The time until the notification expires", "TIMEOUT" }, { "icon", 'i', 0, G_OPTION_ARG_STRING, &icon, "An Icon that should be displayed with the notification", "ICON" }, + { "raw_icon", 'I', 0, G_OPTION_ARG_STRING, &raw_icon_path, "Path to the icon to be sent as raw image data", "RAW_ICON"}, { "capabilities", 'c', 0, G_OPTION_ARG_NONE, &capabilities, "Print the server capabilities and exit", NULL}, { "serverinfo", 's', 0, G_OPTION_ARG_NONE, &serverinfo, "Print server information and exit", NULL}, { "printid", 'p', 0, G_OPTION_ARG_NONE, &printid, "Print id, which can be used to update/replace this notification", NULL}, @@ -266,6 +269,14 @@ int main(int argc, char *argv[]) GError *err = NULL; + if (raw_icon_path) { + notify_notification_set_image_from_pixbuf(n, gdk_pixbuf_new_from_file(raw_icon_path, &err)); + if(err) { + g_printerr("Unable to close notification: %s\n", err->message); + die(1); + } + } + if (close_id > 0) { put_id(n, close_id); notify_notification_close(n, &err);