add support for user defined mpd host, password and port in config file
This commit is contained in:
@@ -7,6 +7,12 @@
|
||||
#
|
||||
## set it in order to make tag editor and renaming files work properly
|
||||
#
|
||||
#mpd_host = "localhost"
|
||||
#
|
||||
#mpd_password = ""
|
||||
#
|
||||
#mpd_port = "6600"
|
||||
#
|
||||
#mpd_music_dir = "/var/lib/mpd/music"
|
||||
#
|
||||
#mpd_connection_timeout = "5"
|
||||
|
||||
@@ -165,6 +165,13 @@ int main(int argc, char *argv[])
|
||||
if (getenv("MPD_PASSWORD"))
|
||||
Mpd->SetPassword(getenv("MPD_PASSWORD"));
|
||||
|
||||
if (Config.mpd_host != "localhost")
|
||||
Mpd->SetHostname(Config.mpd_host);
|
||||
if (Config.mpd_port != 6600)
|
||||
Mpd->SetPort(Config.mpd_port);
|
||||
if (!Config.mpd_password.empty())
|
||||
Mpd->SetPassword(Config.mpd_password);
|
||||
|
||||
Mpd->SetTimeout(Config.mpd_connection_timeout);
|
||||
|
||||
if (argc > 1)
|
||||
|
||||
@@ -162,6 +162,8 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
|
||||
void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
{
|
||||
conf.mpd_host = "localhost";
|
||||
conf.mpd_password = "";
|
||||
conf.mpd_music_dir = "/var/lib/mpd/music/";
|
||||
conf.song_list_format = "{%a - }{%t}|{[.white]%f[/white]}%r{[.green](%l)[/green]}";
|
||||
conf.song_columns_list_format = "(8)[green]{l} (25)[cyan]{a} (40){t} (30)[red]{b}";
|
||||
@@ -204,6 +206,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.now_playing_lyrics = false;
|
||||
conf.local_browser = false;
|
||||
conf.set_window_title = true;
|
||||
conf.mpd_port = 6600;
|
||||
conf.mpd_connection_timeout = 15;
|
||||
conf.crossfade_time = 5;
|
||||
conf.seek_time = 1;
|
||||
@@ -494,11 +497,26 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
{
|
||||
v = GetLineValue(*it);
|
||||
|
||||
if (it->find("mpd_music_dir") != string::npos)
|
||||
if (it->find("mpd_host") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.mpd_host = v;
|
||||
}
|
||||
else if (it->find("mpd_password") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.mpd_password = v;
|
||||
}
|
||||
else if (it->find("mpd_music_dir") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.mpd_music_dir = v + "/";
|
||||
}
|
||||
else if (it->find("mpd_port") != string::npos)
|
||||
{
|
||||
if (StrToInt(v))
|
||||
conf.mpd_port = StrToInt(v);
|
||||
}
|
||||
else if (it->find("mpd_connection_timeout") != string::npos)
|
||||
{
|
||||
if (StrToInt(v))
|
||||
|
||||
@@ -94,6 +94,8 @@ struct ncmpcpp_keys
|
||||
|
||||
struct ncmpcpp_config
|
||||
{
|
||||
string mpd_host;
|
||||
string mpd_password;
|
||||
string mpd_music_dir;
|
||||
string song_list_format;
|
||||
string song_columns_list_format;
|
||||
@@ -144,6 +146,7 @@ struct ncmpcpp_config
|
||||
bool now_playing_lyrics;
|
||||
bool local_browser;
|
||||
|
||||
int mpd_port;
|
||||
int mpd_connection_timeout;
|
||||
int crossfade_time;
|
||||
int seek_time;
|
||||
|
||||
Reference in New Issue
Block a user