settings: provide a way to use alternative location for configuration file
..and whole data folder.
This commit is contained in:
19
doc/config
19
doc/config
@@ -3,6 +3,25 @@
|
|||||||
## ~/.ncmpcpp/config and set up your preferences ##
|
## ~/.ncmpcpp/config and set up your preferences ##
|
||||||
####################################################
|
####################################################
|
||||||
#
|
#
|
||||||
|
##### directories ######
|
||||||
|
##
|
||||||
|
## Directory for storing ncmpcpp related files.
|
||||||
|
## Changing it is useful if you want to store
|
||||||
|
## everything somewhere else and provide command
|
||||||
|
## line setting for alternative location to config
|
||||||
|
## file which defines that while launching ncmpcpp.
|
||||||
|
##
|
||||||
|
#
|
||||||
|
#ncmpcpp_directory = "~/.ncmpcpp"
|
||||||
|
#
|
||||||
|
##
|
||||||
|
## Directory for storing downloaded lyrics. It
|
||||||
|
## defaults to ~/.lyrics since other MPD clients
|
||||||
|
## (eg. ncmpc) also use that location.
|
||||||
|
##
|
||||||
|
#
|
||||||
|
#lyrics_directory = "~/.lyrics"
|
||||||
|
#
|
||||||
##### connection settings #####
|
##### connection settings #####
|
||||||
#
|
#
|
||||||
## set it in order to make tag editor and renaming files work properly
|
## set it in order to make tag editor and renaming files work properly
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Connect to server at host [localhost]
|
|||||||
.B \-p, \-\-port
|
.B \-p, \-\-port
|
||||||
Connect to server at port [6600]
|
Connect to server at port [6600]
|
||||||
.TP
|
.TP
|
||||||
|
.B \-c, \-\-config
|
||||||
|
Use alternative configuration file
|
||||||
|
.TP
|
||||||
.B \-s, \-\-screen <name>
|
.B \-s, \-\-screen <name>
|
||||||
Specify the startup screen (<name> may be: help, playlist, browser, search-engine, media-library, playlist-editor, tag-editor, outputs, visualizer, clock)
|
Specify the startup screen (<name> may be: help, playlist, browser, search-engine, media-library, playlist-editor, tag-editor, outputs, visualizer, clock)
|
||||||
.TP
|
.TP
|
||||||
@@ -57,6 +60,12 @@ Note: COLOR has to be the name (not a number) of one of colors 1-8 from SONG FOR
|
|||||||
|
|
||||||
Supported configuration options:
|
Supported configuration options:
|
||||||
.TP
|
.TP
|
||||||
|
.B ncmpcpp_directory = PATH
|
||||||
|
Directory for storing ncmpcpp related files. Changing it is useful if you want to store everything somewhere else and provide command line setting for alternative location to config file which defines that while launching ncmpcpp.
|
||||||
|
.TP
|
||||||
|
.B lyrics_directory = PATH
|
||||||
|
Directory for storing downloaded lyrics. It defaults to ~/.lyrics since other MPD clients (eg. ncmpc) also use that location.
|
||||||
|
.TP
|
||||||
.B mpd_host = HOST
|
.B mpd_host = HOST
|
||||||
Connect to MPD running on specified host/unix socket. When HOST starts with a '/', it is assumed to be a unix socket.
|
Connect to MPD running on specified host/unix socket. When HOST starts with a '/', it is assumed to be a unix socket.
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ INCLUDES= $(all_includes)
|
|||||||
# the library search path.
|
# the library search path.
|
||||||
ncmpcpp_LDFLAGS = $(all_libraries)
|
ncmpcpp_LDFLAGS = $(all_libraries)
|
||||||
noinst_HEADERS = browser.h charset.h clock.h conv.h curl_handle.h display.h \
|
noinst_HEADERS = browser.h charset.h clock.h conv.h curl_handle.h display.h \
|
||||||
error.h global.h help.h helpers.h home.h lastfm.h lastfm_service.h lyrics.h \
|
error.h global.h help.h helpers.h lastfm.h lastfm_service.h lyrics.h \
|
||||||
lyrics_fetcher.h media_library.h menu.h mpdpp.h outputs.h playlist_editor.h screen.h \
|
lyrics_fetcher.h media_library.h menu.h mpdpp.h outputs.h playlist_editor.h screen.h \
|
||||||
scrollpad.h search_engine.h sel_items_adder.h server_info.h settings.h song.h \
|
scrollpad.h search_engine.h sel_items_adder.h server_info.h settings.h song.h \
|
||||||
song_info.h tag_editor.h tiny_tag_editor.h tolower.h visualizer.h window.h
|
song_info.h tag_editor.h tiny_tag_editor.h tolower.h visualizer.h window.h
|
||||||
|
|||||||
@@ -538,7 +538,9 @@ void Browser::ChangeBrowseMode()
|
|||||||
|
|
||||||
itsBrowseLocally = !itsBrowseLocally;
|
itsBrowseLocally = !itsBrowseLocally;
|
||||||
ShowMessage("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD music dir");
|
ShowMessage("Browse mode: %s", itsBrowseLocally ? "Local filesystem" : "MPD music dir");
|
||||||
itsBrowsedDir = itsBrowseLocally ? home_path : "/";
|
itsBrowsedDir = itsBrowseLocally ? Config.GetHomeDirectory() : "/";
|
||||||
|
if (itsBrowseLocally && *itsBrowsedDir.rbegin() == '/')
|
||||||
|
itsBrowsedDir.resize(itsBrowsedDir.length()-1);
|
||||||
w->Reset();
|
w->Reset();
|
||||||
GetDirectory(itsBrowsedDir);
|
GetDirectory(itsBrowsedDir);
|
||||||
RedrawHeader = 1;
|
RedrawHeader = 1;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef _GLOBAL_H
|
#ifndef _GLOBAL_H
|
||||||
#define _GLOBAL_H
|
#define _GLOBAL_H
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ void ParseArgv(int argc, char **argv)
|
|||||||
<< "Usage: ncmpcpp [OPTION]...\n"
|
<< "Usage: ncmpcpp [OPTION]...\n"
|
||||||
<< " -h, --host connect to server at host [localhost]\n"
|
<< " -h, --host connect to server at host [localhost]\n"
|
||||||
<< " -p, --port connect to server at port [6600]\n"
|
<< " -p, --port connect to server at port [6600]\n"
|
||||||
|
<< " -c, --config use alternative configuration file\n"
|
||||||
<< " -s, --screen <name> specify the startup screen\n"
|
<< " -s, --screen <name> specify the startup screen\n"
|
||||||
<< " -?, --help show this help message\n"
|
<< " -?, --help show this help message\n"
|
||||||
<< " -v, --version display version information\n"
|
<< " -v, --version display version information\n"
|
||||||
@@ -142,7 +143,7 @@ void ParseArgv(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ConnectToMPD())
|
if (!ConnectToMPD())
|
||||||
exit(0);
|
exit(1);
|
||||||
|
|
||||||
if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--screen"))
|
if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--screen"))
|
||||||
{
|
{
|
||||||
@@ -258,6 +259,11 @@ void ParseArgv(int argc, char **argv)
|
|||||||
Mpd.SetVolume(Mpd.GetVolume()+atoi(argv[i]));
|
Mpd.SetVolume(Mpd.GetVolume()+atoi(argv[i]));
|
||||||
quit = 1;
|
quit = 1;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config"))
|
||||||
|
{
|
||||||
|
// this is used in NcmpcppConfig::CheckForCommandLineConfigFilePath, ignoring here.
|
||||||
|
++i;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "ncmpcpp: invalid option: " << argv[i] << std::endl;
|
std::cout << "ncmpcpp: invalid option: " << argv[i] << std::endl;
|
||||||
|
|||||||
47
src/home.h
47
src/home.h
@@ -1,47 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* Copyright (C) 2008-2011 by Andrzej Rybczak *
|
|
||||||
* electricityispower@gmail.com *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program; if not, write to the *
|
|
||||||
* Free Software Foundation, Inc., *
|
|
||||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _HOME_H
|
|
||||||
#define _HOME_H
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# define _WIN32_IE 0x0400
|
|
||||||
# include <shlobj.h>
|
|
||||||
|
|
||||||
inline std::string _GetHomeFolder()
|
|
||||||
{
|
|
||||||
char path[300];
|
|
||||||
return SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, 0) ? path : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
# define GET_HOME_FOLDER _GetHomeFolder()
|
|
||||||
#else
|
|
||||||
# define GET_HOME_FOLDER getenv("HOME") ? getenv("HOME") : "";
|
|
||||||
#endif // WIN32
|
|
||||||
|
|
||||||
const std::string home_path = GET_HOME_FOLDER;
|
|
||||||
|
|
||||||
#undef GET_HOME_FOLDER
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ void Lastfm::SetTitleAndFolder()
|
|||||||
{
|
{
|
||||||
itsTitle = U("Artist info - ");
|
itsTitle = U("Artist info - ");
|
||||||
itsTitle += TO_WSTRING(itsArgs.find("artist")->second);
|
itsTitle += TO_WSTRING(itsArgs.find("artist")->second);
|
||||||
itsFolder = home_path + HOME_FOLDER + "artists";
|
itsFolder = Config.ncmpcpp_directory + "artists";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,6 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#ifdef WIN32
|
|
||||||
# include <io.h>
|
|
||||||
#else
|
|
||||||
# include <sys/stat.h>
|
|
||||||
#endif // WIN32
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "browser.h"
|
#include "browser.h"
|
||||||
@@ -37,19 +32,11 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# define LYRICS_FOLDER HOME_FOLDER"\\lyrics\\"
|
|
||||||
#else
|
|
||||||
# define LYRICS_FOLDER "/.lyrics"
|
|
||||||
#endif // WIN32
|
|
||||||
|
|
||||||
using Global::MainHeight;
|
using Global::MainHeight;
|
||||||
using Global::MainStartY;
|
using Global::MainStartY;
|
||||||
using Global::myScreen;
|
using Global::myScreen;
|
||||||
using Global::myOldScreen;
|
using Global::myOldScreen;
|
||||||
|
|
||||||
std::string Lyrics::itsFolder = home_path + LYRICS_FOLDER;
|
|
||||||
|
|
||||||
#ifdef HAVE_CURL_CURL_H
|
#ifdef HAVE_CURL_CURL_H
|
||||||
LyricsFetcher **Lyrics::itsFetcher = 0;
|
LyricsFetcher **Lyrics::itsFetcher = 0;
|
||||||
std::set<MPD::Song *> Lyrics::itsDownloaded;
|
std::set<MPD::Song *> Lyrics::itsDownloaded;
|
||||||
@@ -288,7 +275,7 @@ std::string Lyrics::GenerateFilename(const MPD::Song &s)
|
|||||||
file += locale_to_utf_cpy(s.GetTitle());
|
file += locale_to_utf_cpy(s.GetTitle());
|
||||||
file += ".txt";
|
file += ".txt";
|
||||||
EscapeUnallowedChars(file);
|
EscapeUnallowedChars(file);
|
||||||
filename = itsFolder;
|
filename = Config.lyrics_directory;
|
||||||
filename += "/";
|
filename += "/";
|
||||||
filename += file;
|
filename += file;
|
||||||
}
|
}
|
||||||
@@ -308,11 +295,7 @@ void Lyrics::Load()
|
|||||||
itsSong.Localize();
|
itsSong.Localize();
|
||||||
itsFilename = GenerateFilename(itsSong);
|
itsFilename = GenerateFilename(itsSong);
|
||||||
|
|
||||||
mkdir(itsFolder.c_str()
|
CreateDir(Config.lyrics_directory);
|
||||||
# ifndef WIN32
|
|
||||||
, 0755
|
|
||||||
# endif // !WIN32
|
|
||||||
);
|
|
||||||
|
|
||||||
w->Clear();
|
w->Clear();
|
||||||
w->Reset();
|
w->Reset();
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
MPD::Song itsSong;
|
MPD::Song itsSong;
|
||||||
std::string itsFilename;
|
std::string itsFilename;
|
||||||
|
|
||||||
static std::string itsFolder;
|
|
||||||
static std::string GenerateFilename(const MPD::Song &s);
|
static std::string GenerateFilename(const MPD::Song &s);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -238,10 +238,11 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
CreateConfigDir();
|
|
||||||
|
Config.CheckForCommandLineConfigFilePath(argv, argc);
|
||||||
|
|
||||||
Config.SetDefaults();
|
Config.SetDefaults();
|
||||||
Key.SetDefaults();
|
Key.SetDefaults();
|
||||||
@@ -265,13 +266,15 @@ int main(int argc, char *argv[])
|
|||||||
ParseArgv(argc, argv);
|
ParseArgv(argc, argv);
|
||||||
|
|
||||||
if (!ConnectToMPD())
|
if (!ConnectToMPD())
|
||||||
return -1;
|
exit(1);
|
||||||
|
|
||||||
|
CreateDir(Config.ncmpcpp_directory);
|
||||||
|
|
||||||
// always execute these commands, even if ncmpcpp use exit function
|
// always execute these commands, even if ncmpcpp use exit function
|
||||||
atexit(do_at_exit);
|
atexit(do_at_exit);
|
||||||
|
|
||||||
// redirect std::cerr output to ~/.ncmpcpp/error.log file
|
// redirect std::cerr output to ~/.ncmpcpp/error.log file
|
||||||
errorlog.open((config_dir + "error.log").c_str(), std::ios::app);
|
errorlog.open((Config.ncmpcpp_directory + "error.log").c_str(), std::ios::app);
|
||||||
cerr_buffer = std::cerr.rdbuf();
|
cerr_buffer = std::cerr.rdbuf();
|
||||||
std::cerr.rdbuf(errorlog.rdbuf());
|
std::cerr.rdbuf(errorlog.rdbuf());
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,13 @@
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
|
# define _WIN32_IE 0x0400
|
||||||
|
# include <shlobj.h>
|
||||||
#else
|
#else
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -46,9 +50,6 @@
|
|||||||
# include <langinfo.h>
|
# include <langinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string config_file = config_dir + "config";
|
|
||||||
const std::string keys_config_file = config_dir + "keys";
|
|
||||||
|
|
||||||
NcmpcppConfig Config;
|
NcmpcppConfig Config;
|
||||||
NcmpcppKeys Key;
|
NcmpcppKeys Key;
|
||||||
|
|
||||||
@@ -148,9 +149,9 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateConfigDir()
|
void CreateDir(const std::string &dir)
|
||||||
{
|
{
|
||||||
mkdir(config_dir.c_str()
|
mkdir(dir.c_str()
|
||||||
# ifndef WIN32
|
# ifndef WIN32
|
||||||
, 0755
|
, 0755
|
||||||
# endif // !WIN32
|
# endif // !WIN32
|
||||||
@@ -476,7 +477,7 @@ void NcmpcppConfig::SetDefaults()
|
|||||||
|
|
||||||
void NcmpcppKeys::Read()
|
void NcmpcppKeys::Read()
|
||||||
{
|
{
|
||||||
std::ifstream f(keys_config_file.c_str());
|
std::ifstream f((Config.ncmpcpp_directory + "keys").c_str());
|
||||||
std::string key, name;
|
std::string key, name;
|
||||||
|
|
||||||
if (!f.is_open())
|
if (!f.is_open())
|
||||||
@@ -666,12 +667,60 @@ void NcmpcppKeys::Read()
|
|||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NcmpcppConfig::NcmpcppConfig()
|
||||||
|
{
|
||||||
|
# ifdef WIN32
|
||||||
|
ncmpcpp_directory = GetHomeDirectory() + "ncmpcpp/";
|
||||||
|
lyrics_directory = ncmpcpp_directory + "lyrics/";
|
||||||
|
# else
|
||||||
|
ncmpcpp_directory = GetHomeDirectory() + ".ncmpcpp/";
|
||||||
|
lyrics_directory = GetHomeDirectory() + ".lyrics/";
|
||||||
|
# endif // WIN32
|
||||||
|
config_file_path = ncmpcpp_directory + "config";
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &NcmpcppConfig::GetHomeDirectory()
|
||||||
|
{
|
||||||
|
if (!home_directory.empty())
|
||||||
|
return home_directory;
|
||||||
|
# ifdef WIN32
|
||||||
|
char path[MAX_PATH];
|
||||||
|
SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, 0);
|
||||||
|
home_directory = path ? path : "";
|
||||||
|
replace(home_directory.begin(), home_directory.end(), '\\', '/');
|
||||||
|
# else
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
home_directory = home ? home : "<unknown>";
|
||||||
|
# endif // WIN32
|
||||||
|
if (!home_directory.empty() && *home_directory.rbegin() != '/')
|
||||||
|
home_directory += '/';
|
||||||
|
return home_directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NcmpcppConfig::CheckForCommandLineConfigFilePath(char **argv, int argc)
|
||||||
|
{
|
||||||
|
if (argc < 3)
|
||||||
|
return;
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config"))
|
||||||
|
{
|
||||||
|
if (++i >= argc)
|
||||||
|
continue;
|
||||||
|
config_file_path = argv[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NcmpcppConfig::Read()
|
void NcmpcppConfig::Read()
|
||||||
{
|
{
|
||||||
std::ifstream f(config_file.c_str());
|
std::ifstream f(config_file_path.c_str());
|
||||||
std::string cl, v, name;
|
std::string cl, v, name;
|
||||||
|
|
||||||
while (f.is_open() && !f.eof())
|
if (!f.is_open())
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (!f.eof())
|
||||||
{
|
{
|
||||||
getline(f, cl);
|
getline(f, cl);
|
||||||
if (!cl.empty() && cl[0] != '#')
|
if (!cl.empty() && cl[0] != '#')
|
||||||
@@ -679,7 +728,23 @@ void NcmpcppConfig::Read()
|
|||||||
name = GetOptionName(cl);
|
name = GetOptionName(cl);
|
||||||
v = GetLineValue(cl);
|
v = GetLineValue(cl);
|
||||||
|
|
||||||
if (name == "mpd_host")
|
if (name == "ncmpcpp_directory")
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
{
|
||||||
|
MakeProperPath(v);
|
||||||
|
ncmpcpp_directory = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (name == "lyrics_directory")
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
{
|
||||||
|
MakeProperPath(v);
|
||||||
|
lyrics_directory = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (name == "mpd_host")
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
mpd_host = v;
|
mpd_host = v;
|
||||||
@@ -688,10 +753,8 @@ void NcmpcppConfig::Read()
|
|||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
{
|
{
|
||||||
// if ~ is used at the beginning, replace it with user's home folder
|
MakeProperPath(v);
|
||||||
if (v[0] == '~')
|
mpd_music_dir = v;
|
||||||
v.replace(0, 1, home_path);
|
|
||||||
mpd_music_dir = v + "/";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (name == "visualizer_fifo_path")
|
else if (name == "visualizer_fifo_path")
|
||||||
@@ -1322,3 +1385,13 @@ void NcmpcppConfig::Read()
|
|||||||
*song_in_columns_to_string_format.rbegin() = '}';
|
*song_in_columns_to_string_format.rbegin() = '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NcmpcppConfig::MakeProperPath(std::string &dir)
|
||||||
|
{
|
||||||
|
if (dir.empty())
|
||||||
|
return;
|
||||||
|
if (dir[0] == '~')
|
||||||
|
dir.replace(0, 1, home_directory);
|
||||||
|
replace(dir.begin(), dir.end(), '\\', '/');
|
||||||
|
if (*dir.rbegin() != '/')
|
||||||
|
dir += '/';
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,17 +25,8 @@
|
|||||||
|
|
||||||
#include <mpd/client.h>
|
#include <mpd/client.h>
|
||||||
|
|
||||||
#include "home.h"
|
|
||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# define HOME_FOLDER "\\ncmpcpp\\"
|
|
||||||
#else
|
|
||||||
# define HOME_FOLDER "/.ncmpcpp/"
|
|
||||||
#endif // WIN32
|
|
||||||
|
|
||||||
const std::string config_dir = home_path + HOME_FOLDER;
|
|
||||||
|
|
||||||
class BasicScreen; // forward declaration for screens sequence
|
class BasicScreen; // forward declaration for screens sequence
|
||||||
|
|
||||||
struct Column
|
struct Column
|
||||||
@@ -151,9 +142,17 @@ struct NcmpcppKeys
|
|||||||
|
|
||||||
struct NcmpcppConfig
|
struct NcmpcppConfig
|
||||||
{
|
{
|
||||||
|
NcmpcppConfig();
|
||||||
|
|
||||||
|
const std::string &GetHomeDirectory();
|
||||||
|
void CheckForCommandLineConfigFilePath(char **argv, int argc);
|
||||||
|
|
||||||
void SetDefaults();
|
void SetDefaults();
|
||||||
void Read();
|
void Read();
|
||||||
|
|
||||||
|
std::string ncmpcpp_directory;
|
||||||
|
std::string lyrics_directory;
|
||||||
|
|
||||||
std::string mpd_host;
|
std::string mpd_host;
|
||||||
std::string mpd_music_dir;
|
std::string mpd_music_dir;
|
||||||
std::string visualizer_fifo_path;
|
std::string visualizer_fifo_path;
|
||||||
@@ -280,12 +279,18 @@ struct NcmpcppConfig
|
|||||||
|
|
||||||
BasicScreen *startup_screen;
|
BasicScreen *startup_screen;
|
||||||
std::list<BasicScreen *> screens_seq;
|
std::list<BasicScreen *> screens_seq;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void MakeProperPath(std::string &dir);
|
||||||
|
|
||||||
|
std::string home_directory;
|
||||||
|
std::string config_file_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NcmpcppKeys Key;
|
extern NcmpcppKeys Key;
|
||||||
extern NcmpcppConfig Config;
|
extern NcmpcppConfig Config;
|
||||||
|
|
||||||
void CreateConfigDir();
|
void CreateDir(const std::string &dir);
|
||||||
void SetWindowsDimensions(size_t &header_height, size_t &footer_start_y, size_t &footer_height);
|
void SetWindowsDimensions(size_t &header_height, size_t &footer_start_y, size_t &footer_height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ using Global::MainStartY;
|
|||||||
|
|
||||||
TagEditor *myTagEditor = new TagEditor;
|
TagEditor *myTagEditor = new TagEditor;
|
||||||
|
|
||||||
const std::string TagEditor::PatternsFile = config_dir + "patterns.list";
|
std::string TagEditor::PatternsFile = "patterns.list";
|
||||||
std::list<std::string> TagEditor::Patterns;
|
std::list<std::string> TagEditor::Patterns;
|
||||||
|
|
||||||
size_t TagEditor::LeftColumnWidth;
|
size_t TagEditor::LeftColumnWidth;
|
||||||
@@ -63,6 +63,7 @@ size_t TagEditor::FParserHeight;
|
|||||||
|
|
||||||
void TagEditor::Init()
|
void TagEditor::Init()
|
||||||
{
|
{
|
||||||
|
PatternsFile = Config.ncmpcpp_directory + "patterns.list";
|
||||||
SetDimensions(0, COLS);
|
SetDimensions(0, COLS);
|
||||||
|
|
||||||
Albums = new Menu<string_pair>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, brNone);
|
Albums = new Menu<string_pair>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, brNone);
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class TagEditor : public Screen<Window>
|
|||||||
std::string itsBrowsedDir;
|
std::string itsBrowsedDir;
|
||||||
std::string itsHighlightedDir;
|
std::string itsHighlightedDir;
|
||||||
|
|
||||||
static const std::string PatternsFile;
|
static std::string PatternsFile;
|
||||||
static std::list<std::string> Patterns;
|
static std::list<std::string> Patterns;
|
||||||
|
|
||||||
static size_t MiddleColumnWidth;
|
static size_t MiddleColumnWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user