overhaul desktop finder

This commit is contained in:
galister
2025-12-28 22:11:23 +09:00
parent 2ff83b63f2
commit 686a6f3ba5
8 changed files with 203 additions and 167 deletions

View File

@@ -7,13 +7,13 @@ edition = "2024"
[dependencies]
wayvr-ipc = { path = "../wayvr-ipc", default-features = false }
freedesktop.workspace = true
anyhow.workspace = true
glam.workspace = true
idmap = { workspace = true, features = ["serde"] }
idmap-derive.workspace = true
log.workspace = true
serde = { workspace = true, features = ["rc"] }
xdg.workspace = true
chrono = "0.4.42"
smol = "2.0.2"

View File

@@ -1,12 +1,16 @@
use std::{path::PathBuf, sync::LazyLock};
use freedesktop::xdg_cache_home;
const FALLBACK_CACHE_PATH: &str = "/tmp/wayvr_cache";
static CACHE_ROOT_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
// Panics if neither $XDG_CACHE_HOME nor $HOME is set
let mut dir = xdg_cache_home();
dir.push("wayvr");
dir
if let Some(mut dir) = xdg::BaseDirectories::new().get_cache_home() {
dir.push("wayvr");
return dir;
}
//Return fallback cache path
log::error!("Err: Failed to find cache path, using {FALLBACK_CACHE_PATH}");
PathBuf::from(FALLBACK_CACHE_PATH) // Panics if neither $XDG_CACHE_HOME nor $HOME is set
});
fn get_cache_root() -> PathBuf {