diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-05 23:12:45 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-05 23:12:45 +0200 |
| commit | 9b6e55fe23890ee89efd5b16605ae44b903471e6 (patch) | |
| tree | 308f12ce7fa3c9c0d05f58e94c1ed2f8149ef0c7 /src/config.rs | |
| parent | Add flexible play command with position flags (diff) | |
| download | rsplayer-9b6e55fe23890ee89efd5b16605ae44b903471e6.tar.gz rsplayer-9b6e55fe23890ee89efd5b16605ae44b903471e6.zip | |
Add dev/release config separation and volume query command
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs index cda59f4..42573ed 100644 --- a/src/config.rs +++ b/src/config.rs | |||
| @@ -20,13 +20,19 @@ pub struct Config { | |||
| 20 | 20 | ||
| 21 | impl Config { | 21 | impl Config { |
| 22 | pub fn load() -> Result<Self, Box<dyn std::error::Error>> { | 22 | pub fn load() -> Result<Self, Box<dyn std::error::Error>> { |
| 23 | let proj_dirs = ProjectDirs::from("com", "rsplayer", "rsplayer") | 23 | let config_dir = if cfg!(debug_assertions) { |
| 24 | .ok_or("Failed to get project directories")?; | 24 | std::env::current_exe()? |
| 25 | 25 | .parent() | |
| 26 | let config_dir = if let Ok(xdg) = std::env::var("XDG_CONFIG_HOME") { | 26 | .map(|p| p.to_path_buf()) |
| 27 | PathBuf::from(xdg).join("rsplayer") | 27 | .unwrap_or_else(|| PathBuf::from(".")) |
| 28 | } else { | 28 | } else { |
| 29 | proj_dirs.config_dir().to_path_buf() | 29 | let proj_dirs = ProjectDirs::from("com", "rsplayer", "rsplayer") |
| 30 | .ok_or("Failed to get project directories")?; | ||
| 31 | if let Ok(xdg) = std::env::var("XDG_CONFIG_HOME") { | ||
| 32 | PathBuf::from(xdg).join("rsplayer") | ||
| 33 | } else { | ||
| 34 | proj_dirs.config_dir().to_path_buf() | ||
| 35 | } | ||
| 30 | }; | 36 | }; |
| 31 | 37 | ||
| 32 | let config_path = config_dir.join("config.toml"); | 38 | let config_path = config_dir.join("config.toml"); |
