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:

"
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 [EMAIL PROTECTED]
"

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
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, 
"connection","hostname","localhost");
+       string =cfg_get_single_value_as_string_with_default(config, 
"connection","hostname","");
+       if(!(string[0]))
+               if(!(string = getenv("MPD_HOST"))) /* FIXME one might want to 
copy this memory or something? */
+                       string = "localhost";
        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,"connection","portnumber", 
6600));
        mpd_ob_set_connection_timeout(connection, 
cfg_get_single_value_as_float_with_default(config,"connection","timeout",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, 
"connection","hostname","localhost");
+       string = cfg_get_single_value_as_string_with_default(config, 
"connection","hostname", "");
        
gtk_entry_set_text(GTK_ENTRY(glade_xml_get_widget(xml_preferences_window, 
"hostname_entry")), string);
        cfg_free_string(string);
        
gtk_spin_button_set_value(GTK_SPIN_BUTTON(glade_xml_get_widget(xml_preferences_window,
 "port_spin")), 

Reply via email to