diff --git a/README.md b/README.md index e700330..ca90bd6 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,13 @@ You can either build the AUR-package yourself, as detailed below, or use your fa ``` ## Configuration -You can configure mpDris using the configuration located at `~/.config/mpd/mpDris.conf` or using command-line arguments. +You can configure mpDris using the configuration file or using command-line arguments. +The config file should either be located in `$XDG_CONFIG_HOME/mpdris/mpdris.conf` or `~/.config/mpdris/mpdris.conf` + +> [!NOTE] +> While the paths `$XDG_CONFIG_HOME/mpd/mpDris.conf` and `$HOME/mpd/mpDris.conf` still work, they are +> deprecated and may be removed in a future update. + The config file has the following options: - addr: The IP address mpDris uses to connect to MPD (default: 127.0.0.1) - port: The port mpDris uses to connect to MPD (default: 6600) diff --git a/resources/sample.mpDris.conf b/resources/sample.mpdris.conf similarity index 100% rename from resources/sample.mpDris.conf rename to resources/sample.mpdris.conf diff --git a/src/util/mod.rs b/src/util/mod.rs index 7610465..86c3b2c 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -3,16 +3,25 @@ use std::{env, io, path::PathBuf, process::exit}; use crate::HOME_DIR; use libc::EXIT_SUCCESS; -use log::debug; +use log::{debug, warn}; pub mod expand; pub mod notify; /// Gets the default config path from the environment. -/// Defined as: $XDG_CONFIG_PATH/mpd/mpDris.conf or $HOME/.config/mpd/mpDris.conf +/// Defined as: $XDG_CONFIG_PATH/mpdris/mpdris.conf or $HOME/.config/mpdris/mpdris.conf +/// Deprecated path: $XDG_CONFIG_PATH/mpd/mpDris.conf or $HOME/.config/mpd/mpDris.conf pub fn get_config_path() -> PathBuf { let base = env::var("XDG_CONFIG_HOME").unwrap_or_else(|_| format!("{}/.config", *HOME_DIR)); - [base.as_str(), "mpd", "mpDris.conf"].iter().collect() + let paths: [PathBuf; 2] = [ + [base.as_str(), "mpdris", "mpdris.conf"].iter().collect(), + [base.as_str(), "mpd", "mpDris.conf"].iter().collect(), + ]; + let idx = paths.iter().position(|p| p.is_file()).unwrap_or(0); + if idx == 1 { + warn!("Using deprecated configuration path `{}`", paths[idx].display()); + } + paths.into_iter().nth(idx).unwrap() } pub fn init_logger(level: log::LevelFilter) {