From 31798fd1c74ca0eec1f90de9639c8d70d42afbe5 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 20 Dec 2020 17:20:41 +0100 Subject: [PATCH] Prefer `$XDG_CONFIG_HOME/ncmpcpp` as a folder with configuration --- CHANGELOG.md | 1 + doc/bindings | 4 ++-- doc/config | 11 ++++++----- doc/ncmpcpp.1 | 13 +++++++++++-- src/configuration.cpp | 8 ++++---- src/ncmpcpp.cpp | 2 +- src/settings.cpp | 2 +- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0a7835..6d06f138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * Deprecate `visualizer_sync_interval` configuration option. * Deprecate `noop` value of `browser_sort_mode` in favor of `none`. * 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) * Help screen: fixed display of EoF keycode diff --git a/doc/bindings b/doc/bindings index 52d53028..8e75f032 100644 --- a/doc/bindings +++ b/doc/bindings @@ -1,7 +1,7 @@ ############################################################## ## This is the example bindings file. Copy it to ## -## ~/.ncmpcpp/bindings or $XDG_CONFIG_HOME/ncmpcpp/bindings ## -## and set up your preferences ## +## $XDG_CONFIG_HOME/ncmpcpp/bindings or ~/.ncmpcpp/bindings ## +## and set up your preferences. ## ############################################################## ## ##### General rules ##### diff --git a/doc/config b/doc/config index 4fc4cae0..c7ef39cf 100644 --- a/doc/config +++ b/doc/config @@ -1,7 +1,8 @@ -############################################################################## -## This is the example configuration file. Copy it to $HOME/.ncmpcpp/config ## -## or $XDG_CONFIG_HOME/ncmpcpp/config and set up your preferences. ## -############################################################################## +############################################################## +## This is an example configuration file. Copy it to ## +## $XDG_CONFIG_HOME/ncmpcpp/config or $HOME/.ncmpcpp/config ## +## and set up your preferences. ## +############################################################## # ##### directories ###### ## @@ -11,7 +12,7 @@ ## ncmpcpp. ## # -#ncmpcpp_directory = ~/.ncmpcpp +#ncmpcpp_directory = ~/.config/ncmpcpp # ## ## Directory for storing downloaded lyrics. It defaults to ~/.lyrics since other diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 83bcd3c9..f6275f02 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -45,7 +45,12 @@ Display help. Display version information. .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. - 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. .TP .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. .SH "SONG FORMAT" diff --git a/src/configuration.cpp b/src/configuration.cpp index b7d80d75..ce0dfddf 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -74,13 +74,13 @@ void expand_home(std::string &path) bool configure(int argc, char **argv) { const std::vector default_config_paths = { - "~/.ncmpcpp/config", - xdg_config_home() + "ncmpcpp/config" + xdg_config_home() + "ncmpcpp/config", + "~/.ncmpcpp/config" }; const std::vector default_bindings_paths = { - "~/.ncmpcpp/bindings", - xdg_config_home() + "ncmpcpp/bindings" + xdg_config_home() + "ncmpcpp/bindings", + "~/.ncmpcpp/bindings" }; std::vector bindings_paths; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index f4385468..a186c6aa 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -103,7 +103,7 @@ int main(int argc, char **argv) // always execute these commands, even if ncmpcpp use exit function 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); cerr_buffer = std::cerr.rdbuf(); std::cerr.rdbuf(errorlog.rdbuf()); diff --git a/src/settings.cpp b/src/settings.cpp index 2d8a0ba2..d9c88e41 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -235,7 +235,7 @@ bool Configuration::read(const std::vector &config_paths, bool igno }); // 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("mpd_host", nullptr, "localhost", [](std::string host) { expand_home(host);