[From nobody Wed Oct 28 18:39:09 2026
Received: (at submit) by bugs.debian.org; 15 Oct 2005 07:30:51 +0000
Return-path: &lt;debianbts@cos.user.lysator.liu.se&gt;
Received: from mxfep02.bredband.com [195.54.107.73] 
 by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
 id 1EQgVH-0004Ow-00; Sat, 15 Oct 2005 00:30:51 -0700
Received: from laga ([213.114.66.118] [213.114.66.118])
 by mxfep02.bredband.com with ESMTP
 id &lt;20051015073046.PMGD11792.mxfep02.bredband.com@laga&gt;
 for &lt;submit@bugs.debian.org&gt;; Sat, 15 Oct 2005 09:30:46 +0200
Received: from [192.168.2.121] (helo=localhost.localdomain ident=Debian-exim)
 by laga with esmtp (Exim 4.34) id 1EQgVB-0002l5-TV
 for submit@bugs.debian.org; Sat, 15 Oct 2005 09:30:46 +0200
Received: from localhost ([127.0.0.1] helo=leka ident=cos)
 by localhost.localdomain with esmtp (Exim 4.52) id 1EQgUD-0006uq-8U
 for submit@bugs.debian.org; Sat, 15 Oct 2005 09:29:45 +0200
Date: Sat, 15 Oct 2005 09:29:45 +0200
From: Martin Samuelsson &lt;debianbts@cos.user.lysator.liu.se&gt;
To: submit@bugs.debian.org
Subject: gmpc configurable with env variables
Message-ID: &lt;20051015072944.GA26568@ch.lugn.nu&gt;
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=&quot;sdtB3X0nJg68CQEu&quot;
Content-Disposition: inline
X-Debbugs-Cc: qball@qballcow.nl
User-Agent: mutt-ng 1.5.9-r271i (Debian)
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
 (1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-11.0 required=4.0 tests=BAYES_00,HAS_PACKAGE,
 X_DEBBUGS_CC autolearn=ham version=2.60-bugs.debian.org_2005_01_02


--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Package: gmpc
Version: 0.12-1
Severity: wishlist

When using my laptop and being on the move I want to control the locally
running mpd, but when I am at home I prefer having music coming out of my
stereo. As the software is designed now such a usage can't be done elegantly.

If gmpc used the values of the MPD_HOST and MPD_PORT the same way mpc does, a
simple wrapper script could be used to set those prior to starting it.

For reference, I'm quoting the mpc man page:

&quot;
ENVIRONMENT
    This section describes some environment variables that affect how mpc operates.
       MPD_HOST
       MPD_PORT
     By default, mpc connects to localhost:6600. This can be  changed  either
     at compile- time, or by exporting the MPD_HOST and MPD_PORT environment
     variables.  To use a password with mpd, set MPD_HOST to password@host.
&quot;

In the gmpc case it should probably be the configured values as the first
try, environmental variables if they are empty and localhost as a last
resort.

Do you think this would be a feature worth adding? Attached is a patch with a
partial support for this. I.e. it handles the host MPD_HOST, but not password
or port configuration. And it probably leaks memory. It is more an aid in
deciding if adding the feature or not, than something in the shape to be
included as is.

Upstream is X-Debbugs-Cc:ed.
--
/Martin

--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=&quot;gmpc-env.diff&quot;

diff -ur gmpc-0.12.0/src/mpdinteraction.c gmpc-0.12.0-env/src/mpdinteraction.c
--- gmpc-0.12.0/src/mpdinteraction.c	2005-07-16 16:15:59.000000000 +0200
+++ gmpc-0.12.0-env/src/mpdinteraction.c	2005-10-15 09:11:14.019734133 +0200
@@ -56,11 +56,15 @@
 int connect_to_mpd()
 {
 	char *string = NULL;
+
 	scroll.exposed = 1;
 	info.playlist_playtime = 0;
-	string =cfg_get_single_value_as_string_with_default(config, &quot;connection&quot;,&quot;hostname&quot;,&quot;localhost&quot;);
+	string =cfg_get_single_value_as_string_with_default(config, &quot;connection&quot;,&quot;hostname&quot;,&quot;&quot;);
+	if(!(string[0]))
+		if(!(string = getenv(&quot;MPD_HOST&quot;))) /* FIXME one might want to copy this memory or something? */
+			string = &quot;localhost&quot;;
 	mpd_ob_set_hostname(connection,string);
-	cfg_free_string(string);
+	cfg_free_string(string); /* FIXME will this free in all cases? */
 	mpd_ob_set_port(connection, cfg_get_single_value_as_int_with_default(config,&quot;connection&quot;,&quot;portnumber&quot;, 6600));
 	mpd_ob_set_connection_timeout(connection, cfg_get_single_value_as_float_with_default(config,&quot;connection&quot;,&quot;timeout&quot;,1.0));
 
diff -ur gmpc-0.12.0/src/preferences.c gmpc-0.12.0-env/src/preferences.c
--- gmpc-0.12.0/src/preferences.c	2005-08-06 21:18:35.000000000 +0200
+++ gmpc-0.12.0-env/src/preferences.c	2005-10-15 09:12:05.998443263 +0200
@@ -72,7 +72,7 @@
 
 	/* set info from struct */
 	/* hostname */
-	string = cfg_get_single_value_as_string_with_default(config, &quot;connection&quot;,&quot;hostname&quot;,&quot;localhost&quot;);
+	string = cfg_get_single_value_as_string_with_default(config, &quot;connection&quot;,&quot;hostname&quot;, &quot;&quot;);
 	gtk_entry_set_text(GTK_ENTRY(glade_xml_get_widget(xml_preferences_window, &quot;hostname_entry&quot;)), string);
 	cfg_free_string(string);
 	gtk_spin_button_set_value(GTK_SPIN_BUTTON(glade_xml_get_widget(xml_preferences_window, &quot;port_spin&quot;)), 

--sdtB3X0nJg68CQEu--

]