summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--mpd-notification.c19
2 files changed, 18 insertions, 2 deletions
diff --git a/README.md b/README.md
index 4f2bd8e..dd876ec 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,7 @@ or `systemctl --user enable mpd-notification`.
* *-o*: Notification text is one line (no line breaks)
* *-p PORT*: connect to *PORT*
* *-t TIMEOUT*: notification timeout, *TIMEOUT* in seconds
+* *-s PIXELS*: scale image to *PIXELS* x *PIXELS* pixels
* *-v*: verbose output
* *-V*: print version information
diff --git a/mpd-notification.c b/mpd-notification.c
index 9e7f1f7..c271131 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -7,7 +7,7 @@
#include "mpd-notification.h"
-const static char optstring[] = "hH:m:op:t:vV";
+const static char optstring[] = "hH:m:op:s:t:vV";
const static struct option options_long[] = {
/* name has_arg flag val */
{ "help", no_argument, NULL, 'h' },
@@ -15,6 +15,7 @@ const static struct option options_long[] = {
{ "music-dir", required_argument, NULL, 'm' },
{ "oneline", no_argument, NULL, 'o' },
{ "port", required_argument, NULL, 'p' },
+ { "scale", required_argument, NULL, 's' },
{ "timeout", required_argument, NULL, 't' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
@@ -181,7 +182,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;
+ unsigned int i, version = 0, help = 0, scale = 0;
program = argv[0];
@@ -245,6 +246,9 @@ int main(int argc, char ** argv) {
if (verbose > 0)
printf("%s: using host %s\n", program, mpd_host);
break;
+ case 's':
+ scale = atof(optarg);
+ break;
case 't':
notification_timeout = atof(optarg) * 1000;
if (verbose > 0)
@@ -333,10 +337,21 @@ int main(int argc, char ** argv) {
uri = mpd_song_get_uri(song);
if (music_dir != NULL && uri != NULL) {
+ GdkPixbuf * copy;
+
pixbuf = retrieve_artwork(music_dir, uri);
if (verbose > 0 && pixbuf != NULL)
printf("%s: found artwork in or near media file: %s/%s\n", program, music_dir, uri);
+
+ if (scale > 0) {
+ if ((copy = gdk_pixbuf_scale_simple (pixbuf, scale, scale, GDK_INTERP_BILINEAR)) != NULL) {
+ g_object_unref(pixbuf);
+ pixbuf = copy;
+ }
+ }
+
+
}
mpd_song_free(song);