diff options
author | Christian Hesse <mail@eworm.de> | 2013-10-22 10:58:04 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2013-10-22 10:58:04 +0200 |
commit | e793219fbae56376ed77bef87040a163dfb8dd36 (patch) | |
tree | 4e13c3433f8df5366a45b337a7559ebe170a0f8d | |
parent | 0001f2b17147bdb825a4b2b7212c3f34ead78518 (diff) | |
download | mpd-notification-e793219fbae56376ed77bef87040a163dfb8dd36.tar.gz mpd-notification-e793219fbae56376ed77bef87040a163dfb8dd36.tar.zst |
add mpd host configuration options
-rw-r--r-- | config.def.h | 12 | ||||
-rw-r--r-- | mpd-notification.c | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index f135a8d..48de332 100644 --- a/config.def.h +++ b/config.def.h @@ -10,3 +10,15 @@ #define TEXT_STOP "Stopped playback" #define TEXT_NONE "No action received yet." #define TEXT_UNKNOWN "(unknown)" + +/* how to connect to mpd host ? + * MPD_HOST is the server's host name, IP address or Unix socket path. If the + * resolver returns more than one IP address for a host name, this functions + * tries all of them until one accepts the connection. NULL is allowed here, + * which will connect to the default host. + * MPD_PORT is the TCP port to connect to, 0 for default port. If "host" is + * a Unix socket path, this parameter is ignored. + * MPD_TIMEOUT is the timeout in milliseconds, 0 for the default timeout. */ +#define MPD_HOST NULL +#define MPD_PORT 0 +#define MPD_TIMEOUT 0 diff --git a/mpd-notification.c b/mpd-notification.c index 7144401..a2e2295 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -43,6 +43,8 @@ int main(int argc, char ** argv) { char * album = NULL, * artist = NULL, * notifystr = NULL, * title = NULL; GError * error = NULL; unsigned short int errcount = 0, state = MPD_STATE_UNKNOWN; + const char * mpd_host = MPD_HOST; + unsigned mpd_port = MPD_PORT, mpd_timeout = MPD_TIMEOUT; struct mpd_connection * conn = NULL; struct mpd_song * song = NULL; @@ -58,7 +60,7 @@ int main(int argc, char ** argv) { printf("%s: Started with PID %d\n", program, getpid()); # endif - conn = mpd_connection_new(NULL, 0, 30000); + conn = mpd_connection_new(mpd_host, mpd_port, mpd_timeout); if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) { fprintf(stderr,"%s: %s\n", program, mpd_connection_get_error_message(conn)); |