diff options
author | Christian Hesse <mail@eworm.de> | 2016-10-05 22:09:18 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2016-10-05 22:41:29 +0200 |
commit | 9c5d990ff88ac3055623f7b9b3429bce52a0e11d (patch) | |
tree | afa9d46bf3aa8914f8d274e213c5ba48198932c0 /mpd-notification.c | |
parent | keep aspect ratio when scaling (diff) | |
download | mpd-notification-9c5d990ff88ac3055623f7b9b3429bce52a0e11d.tar.gz mpd-notification-9c5d990ff88ac3055623f7b9b3429bce52a0e11d.tar.bz2 mpd-notification-9c5d990ff88ac3055623f7b9b3429bce52a0e11d.tar.xz mpd-notification-9c5d990ff88ac3055623f7b9b3429bce52a0e11d.tar.zst mpd-notification-9c5d990ff88ac3055623f7b9b3429bce52a0e11d.zip |
add notification file workaround
Diffstat (limited to 'mpd-notification.c')
-rw-r--r-- | mpd-notification.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/mpd-notification.c b/mpd-notification.c index 8713947..840d4ab 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -19,6 +19,8 @@ const static struct option options_long[] = { { "timeout", required_argument, NULL, 't' }, { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, + { "notification-file-workaround", + no_argument, NULL, OPT_FILE_WORKAROUND }, { 0, 0, 0, 0 } }; @@ -182,7 +184,7 @@ int main(int argc, char ** argv) { const char * mpd_host, * mpd_port_str, * music_dir, * uri = NULL; unsigned mpd_port = MPD_PORT, mpd_timeout = MPD_TIMEOUT, notification_timeout = NOTIFICATION_TIMEOUT; struct mpd_song * song = NULL; - unsigned int i, version = 0, help = 0, scale = 0; + unsigned int i, version = 0, help = 0, scale = 0, file_workaround = 0; program = argv[0]; @@ -254,6 +256,9 @@ int main(int argc, char ** argv) { if (verbose > 0) printf("%s: using notification-timeout %d\n", program, notification_timeout); break; + case OPT_FILE_WORKAROUND: + file_workaround++; + break; } } @@ -373,8 +378,14 @@ int main(int argc, char ** argv) { if (verbose > 0) printf("%s: %s\n", program, notifystr); - notify_notification_update(notification, TEXT_TOPIC, notifystr, - ICON_AUDIO_X_GENERIC); + /* Some notification daemons do not support handing pixbuf data. Write a PNG + * file and give the path. */ + if (file_workaround > 0 && pixbuf != NULL) { + gdk_pixbuf_save(pixbuf, "/tmp/.mpd-notification-artwork.png", "png", NULL, NULL); + + notify_notification_update(notification, TEXT_TOPIC, notifystr, "/tmp/.mpd-notification-artwork.png"); + } else + notify_notification_update(notification, TEXT_TOPIC, notifystr, ICON_AUDIO_X_GENERIC); /* Call this unconditionally! When pixbuf is NULL this clears old image. */ notify_notification_set_image_from_pixbuf(notification, pixbuf); |