fix broken xdg path search

This commit is contained in:
LordGrimmauld 2024-03-29 14:50:42 +01:00
parent 81f612ecbf
commit b6ce0ccb52
5 changed files with 189 additions and 175 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
target target
# Cargo.lock # Cargo.lock
result result
.idea

350
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rmenu" name = "rmenu"
version = "0.0.1" version = "1.1.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -30,3 +30,4 @@ shellexpand = "3.1.0"
strfmt = "0.2.4" strfmt = "0.2.4"
thiserror = "1.0.43" thiserror = "1.0.43"
which = "4.4.0" which = "4.4.0"
xdg = "2.5.2"

View File

@ -10,7 +10,7 @@ use rmenu_plugin::{Entry, Message};
use thiserror::Error; use thiserror::Error;
use crate::config::{cfg_replace, Config, Keybind}; use crate::config::{cfg_replace, Config, Keybind};
use crate::{CONFIG_DIR, DEFAULT_CONFIG, DEFAULT_THEME}; use crate::{DEFAULT_CONFIG, DEFAULT_THEME};
/// Allowed Formats for Entry Ingestion /// Allowed Formats for Entry Ingestion
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -182,8 +182,10 @@ impl Args {
/// Find Configuration Path /// Find Configuration Path
pub fn find_config(&self) -> PathBuf { pub fn find_config(&self) -> PathBuf {
self.config.clone().unwrap_or_else(|| { self.config.clone().unwrap_or_else(|| {
let cfgdir = std::env::var("XDG_CONFIG_DIR").unwrap_or_else(|_| CONFIG_DIR.to_string()); xdg::BaseDirectories::with_prefix("rmenu")
PathBuf::from(cfgdir).join(DEFAULT_CONFIG) .expect("Failed to read xdg base dirs")
.find_config_file(DEFAULT_CONFIG)
.unwrap_or_else(PathBuf::new)
}) })
} }

2
rust-toolchain.toml Normal file
View File

@ -0,0 +1,2 @@
[toolchain]
channel = "stable"