Prefer $XDG_CONFIG_HOME/ncmpcpp as a folder with configuration

This commit is contained in:
Andrzej Rybczak
2020-12-20 17:20:41 +01:00
parent 451856afd3
commit 31798fd1c7
7 changed files with 26 additions and 15 deletions

View File

@@ -29,6 +29,7 @@
* Deprecate `visualizer_sync_interval` configuration option. * Deprecate `visualizer_sync_interval` configuration option.
* Deprecate `noop` value of `browser_sort_mode` in favor of `none`. * Deprecate `noop` value of `browser_sort_mode` in favor of `none`.
* Add `type` value of `browser_sort_mode` (set by default). * Add `type` value of `browser_sort_mode` (set by default).
* Prefer `$XDG_CONFIG_HOME/ncmpcpp` as a folder with configuration.
# ncmpcpp-0.8.2 (2018-04-11) # ncmpcpp-0.8.2 (2018-04-11)
* Help screen: fixed display of EoF keycode * Help screen: fixed display of EoF keycode

View File

@@ -1,7 +1,7 @@
############################################################## ##############################################################
## This is the example bindings file. Copy it to ## ## This is the example bindings file. Copy it to ##
## ~/.ncmpcpp/bindings or $XDG_CONFIG_HOME/ncmpcpp/bindings ## ## $XDG_CONFIG_HOME/ncmpcpp/bindings or ~/.ncmpcpp/bindings ##
## and set up your preferences ## ## and set up your preferences. ##
############################################################## ##############################################################
## ##
##### General rules ##### ##### General rules #####

View File

@@ -1,7 +1,8 @@
############################################################################## ##############################################################
## This is the example configuration file. Copy it to $HOME/.ncmpcpp/config ## ## This is an example configuration file. Copy it to ##
## or $XDG_CONFIG_HOME/ncmpcpp/config and set up your preferences. ## ## $XDG_CONFIG_HOME/ncmpcpp/config or $HOME/.ncmpcpp/config ##
############################################################################## ## and set up your preferences. ##
##############################################################
# #
##### directories ###### ##### directories ######
## ##
@@ -11,7 +12,7 @@
## ncmpcpp. ## ncmpcpp.
## ##
# #
#ncmpcpp_directory = ~/.ncmpcpp #ncmpcpp_directory = ~/.config/ncmpcpp
# #
## ##
## Directory for storing downloaded lyrics. It defaults to ~/.lyrics since other ## Directory for storing downloaded lyrics. It defaults to ~/.lyrics since other

View File

@@ -45,7 +45,12 @@ Display help.
Display version information. Display version information.
.SH "CONFIGURATION" .SH "CONFIGURATION"
When ncmpcpp starts, it tries to read user's settings from $HOME/.ncmpcpp/config and $XDG_CONFIG_HOME/ncmpcpp/config files. If no configuration is found, ncmpcpp uses its default configuration. An example configuration file containing all default values is provided with ncmpcpp and can be usually found in /usr/share/doc/ncmpcpp (exact location may depend on used distribution or configure prefix). When ncmpcpp starts, it tries to read settings from
$XDG_CONFIG_HOME/ncmpcpp/config and $HOME/.ncmpcpp/config files. If no
configuration is found, ncmpcpp uses its default configuration. An example
configuration file containing all default values is provided with ncmpcpp and
can be usually found in /usr/share/doc/ncmpcpp (the exact location may depend on
your operating system or configure prefix).
Note: Configuration option values can either be enclosed in quotation marks or not. Note: Configuration option values can either be enclosed in quotation marks or not.
- If they are enclosed, the leftmost and the rightmost quotation marks are treated as delimiters, therefore it is not necessary to escape quotation marks you use within the value itself. - If they are enclosed, the leftmost and the rightmost quotation marks are treated as delimiters, therefore it is not necessary to escape quotation marks you use within the value itself.
@@ -442,7 +447,11 @@ Border color of pop-up windows. If set to 'none', no border will be shown.
Color of active window's border. Color of active window's border.
.TP .TP
.SH "BINDINGS" .SH "BINDINGS"
When ncmpcpp starts, it tries to read user's bindings from ~/.ncmpcpp/bindings and $XDG_CONFIG_HOME/ncmpcpp/bindings files. If no bindings file is found, ncmpcpp uses the defaults. An example bindings file with the default values can be found usually in /usr/share/doc/ncmpcpp (exact location may depend on used distribution or configure prefix). When ncmpcpp starts, it tries to read bindings from
$XDG_CONFIG_HOME/ncmpcpp/bindings and ~/.ncmpcpp/bindings files. If no bindings
file is found, ncmpcpp uses the defaults. An example bindings file with default
values can be found usually in /usr/share/doc/ncmpcpp (the exact location may
depend on your operating system or configure prefix).
You can view current keybindings by pressing F1. You can view current keybindings by pressing F1.
.SH "SONG FORMAT" .SH "SONG FORMAT"

View File

@@ -74,13 +74,13 @@ void expand_home(std::string &path)
bool configure(int argc, char **argv) bool configure(int argc, char **argv)
{ {
const std::vector<std::string> default_config_paths = { const std::vector<std::string> default_config_paths = {
"~/.ncmpcpp/config", xdg_config_home() + "ncmpcpp/config",
xdg_config_home() + "ncmpcpp/config" "~/.ncmpcpp/config"
}; };
const std::vector<std::string> default_bindings_paths = { const std::vector<std::string> default_bindings_paths = {
"~/.ncmpcpp/bindings", xdg_config_home() + "ncmpcpp/bindings",
xdg_config_home() + "ncmpcpp/bindings" "~/.ncmpcpp/bindings"
}; };
std::vector<std::string> bindings_paths; std::vector<std::string> bindings_paths;

View File

@@ -103,7 +103,7 @@ int main(int argc, char **argv)
// 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 the error.log file
errorlog.open((Config.ncmpcpp_directory + "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());

View File

@@ -235,7 +235,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
}); });
// keep the same order of variables as in configuration file // keep the same order of variables as in configuration file
p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory); p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.config/ncmpcpp/", adjust_directory);
p.add("lyrics_directory", &lyrics_directory, "~/.lyrics/", adjust_directory); p.add("lyrics_directory", &lyrics_directory, "~/.lyrics/", adjust_directory);
p.add<void>("mpd_host", nullptr, "localhost", [](std::string host) { p.add<void>("mpd_host", nullptr, "localhost", [](std::string host) {
expand_home(host); expand_home(host);