From f3de6800da042ec6cf1ccd309687332d7c75aaa6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 16 Nov 2015 15:45:48 +0100 Subject: read environment variables: MPD_HOST and MPD_PORT Fixes #6 --- mpd-notification.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mpd-notification.c b/mpd-notification.c index 65fa380..7002845 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -178,13 +178,21 @@ int main(int argc, char ** argv) { GdkPixbuf * pixbuf = NULL; GError * error = NULL; unsigned short int errcount = 0, state = MPD_STATE_UNKNOWN; - const char * mpd_host = MPD_HOST, * music_dir = NULL, * uri = NULL; + 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; program = argv[0]; + if ((mpd_host = getenv("MPD_HOST")) == NULL) + mpd_host = MPD_HOST; + + if ((mpd_port_str = getenv("MPD_PORT")) == NULL) + mpd_port = MPD_PORT; + else + mpd_port = atoi(mpd_port_str); + music_dir = getenv("XDG_MUSIC_DIR"); /* get the verbose status */ -- cgit v1.2.3-70-g09d2