summarylogtreecommitdiffstats
path: root/xdg.patch
diff options
context:
space:
mode:
authorEray Aydın2023-08-08 14:28:31 +0300
committerEray Aydın2023-08-08 14:35:14 +0300
commit9dee47eb9fa8c10d8262bbbefb65e72e9cce1201 (patch)
tree18debc2e6c5662ca93ecfd4bad60d94410441c98 /xdg.patch
downloadaur-earbuds-xdg-git.tar.gz
feat: first initialize of the package
Diffstat (limited to 'xdg.patch')
-rw-r--r--xdg.patch31
1 files changed, 31 insertions, 0 deletions
diff --git a/xdg.patch b/xdg.patch
new file mode 100644
index 000000000000..6e703867c94f
--- /dev/null
+++ b/xdg.patch
@@ -0,0 +1,31 @@
+diff --git a/src/daemon/buds_config.rs b/src/daemon/buds_config.rs
+index 3929269..42aac1d 100644
+--- a/src/daemon/buds_config.rs
++++ b/src/daemon/buds_config.rs
+@@ -164,7 +164,11 @@ impl Config {
+
+ // Create missing folders and return the config file
+ pub async fn get_config_file() -> Result<PathBuf, String> {
+- let conf_dir: PathBuf = get_home_dir().unwrap().join(".config").join("livebuds");
++ let conf_home: PathBuf = match get_xdg_config() {
++ Some(x) => x,
++ None => get_home_dir().unwrap().join(".config")
++ };
++ let conf_dir: PathBuf = conf_home.join("livebuds");
+
+ if !conf_dir.exists().await {
+ fs::create_dir_all(&conf_dir)
+@@ -176,6 +180,13 @@ impl Config {
+ }
+ }
+
++pub fn get_xdg_config() -> Option<PathBuf> {
++ std::env::var_os("XDG_CONFIG_HOME")
++ .and_then(|xdg| if xdg.is_empty() { None } else { Some(xdg) })
++ .or(None)
++ .map(PathBuf::from)
++}
++
+ pub fn get_home_dir() -> Option<PathBuf> {
+ std::env::var_os("HOME")
+ .and_then(|home| if home.is_empty() { None } else { Some(home) })