diff --git a/NEWS b/NEWS index 989ca9ab..741a38b6 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ncmpc 0.50 - not yet released * build: require Meson 0.56 * lyrics/musixmatch: add new lyrics extension * lyrics/google: fix partial loading of lyrics +* fix config file overriding MPD_HOST environment variable ncmpc 0.49 - (2023-08-04) * fix UI freeze if lyrics plugin is stuck diff --git a/src/Main.cxx b/src/Main.cxx index 581e5f69..48aa2282 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -301,6 +301,9 @@ try { GetGlobalKeyBindings().Check(nullptr, 0); #endif + /* set options from environment variables */ + options_env(); + /* parse command line options - 2 pass */ options_parse(argc, argv); diff --git a/src/Options.cxx b/src/Options.cxx index 1671c7c3..5c276414 100644 --- a/src/Options.cxx +++ b/src/Options.cxx @@ -320,7 +320,11 @@ options_parse(int argc, const char *argv[]) handle_option(opt->shortopt, nullptr); else if (opt && opt->argument) option_error(ERROR_MISSING_ARGUMENT, opt->longopt, opt->argument); +} - if (options.host.empty() && getenv("MPD_HOST")) +void +options_env() +{ + if (getenv("MPD_HOST")) options.host = getenv("MPD_HOST"); } diff --git a/src/Options.hxx b/src/Options.hxx index 4df5977e..60d4265a 100644 --- a/src/Options.hxx +++ b/src/Options.hxx @@ -97,4 +97,6 @@ extern Options options; void options_parse(int argc, const char **argv); +void options_env(); + #endif