aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2015-11-16 15:45:48 +0100
committerGravatar Christian Hesse <mail@eworm.de>2015-11-16 15:45:48 +0100
commitf3de6800da042ec6cf1ccd309687332d7c75aaa6 (patch)
treeda90c8b45f17b71ddfb8683cfe2c8b934cb9e567
parent1b2c81c750fd64edb5eb599a5a5ea0265d3852aa (diff)
downloadmpd-notification-f3de6800da042ec6cf1ccd309687332d7c75aaa6.tar.gz
mpd-notification-f3de6800da042ec6cf1ccd309687332d7c75aaa6.tar.zst
read environment variables: MPD_HOST and MPD_PORT
Fixes #6
-rw-r--r--mpd-notification.c10
1 files changed, 9 insertions, 1 deletions
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 */