From 89b62f6c63b53635954a71903a2c79da05e8f29d Mon Sep 17 00:00:00 2001 From: "J. Gerhards" Date: Mon, 9 Jun 2025 14:44:42 +0200 Subject: [PATCH 1/3] Change config path and deprecate old one Change the path of the configuration file to $XDG_CONFIG_HOME/mpdris/mpdris.conf since it is more appropriate for the application to have its own directory. --- src/util/mod.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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) { From 8e7d5d6f92132eea6704458f14309f28dfab291a Mon Sep 17 00:00:00 2001 From: "J. Gerhards" Date: Mon, 9 Jun 2025 14:51:29 +0200 Subject: [PATCH 2/3] Rename sample.mpDris.conf to be lowercase Since the main config file is now lowercase, the sample one should be too. --- resources/{sample.mpDris.conf => sample.mpdris.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resources/{sample.mpDris.conf => sample.mpdris.conf} (100%) 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 From 4bd8e5e2b304e44d557ba3cc95b60a75c25f67b4 Mon Sep 17 00:00:00 2001 From: "J. Gerhards" Date: Mon, 9 Jun 2025 14:53:35 +0200 Subject: [PATCH 3/3] Update README with new configuration paths Update the configuration paths in the readme to the new ones and add a note to notify the users of the deprecated paths. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)