diff --git a/NEWS b/NEWS index 147ec074..d94aa727 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ ncmpc 0.50 - not yet released * lyrics/musixmatch: add new lyrics extension * lyrics/google: fix partial loading of lyrics * support MPD 0.22 tag "label" (requires libmpdclient 2.17) +* 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 1746899a..715486a3 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -288,6 +288,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 dac25b31..03ecbbc1 100644 --- a/src/Options.cxx +++ b/src/Options.cxx @@ -321,7 +321,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 1794a0c9..5e2a5db9 100644 --- a/src/Options.hxx +++ b/src/Options.hxx @@ -78,3 +78,5 @@ struct Options { extern Options options; void options_parse(int argc, const char **argv); + +void options_env();