Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
15 changes: 12 additions & 3 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading