//! Where the Fennec OS sockets and files live. The app paths (data folder, //! settings file) come from the Fennec SDK (`sf_app::paths`). use std::path::{Path, PathBuf}; pub use sf_app::paths::{app_data_dir, runtime_dir, settings_file}; fn from_env(var: &str, default: &str) -> PathBuf { match std::env::var_os(var) { Some(p) => p.into(), None => runtime_dir().join(default), } } /// Launcher command socket (`home`, `remote `, `power`, `wake`). pub fn launcher_socket() -> PathBuf { from_env("SMARTFOX_SOCKET", "smartfox.sock") } /// sf-core: app lifecycle (JSON lines, see `message`). pub fn core_socket() -> PathBuf { from_env("SMARTFOX_CORE_SOCKET", "smartfox-core.sock") } /// sf-compositor control socket (`focus launcher`, `focus `). pub fn wm_socket() -> PathBuf { from_env("SMARTFOX_WM_SOCKET", "smartfox-wm.sock") } /// Installed store apps (`/var/lib/sf-pkg/store/apps/`), written by sf-update. pub const STORE_APPS: &str = "/var/lib/sf-pkg/store/apps"; /// Looks for an `apps` folder next to the binary or above the cwd (dev /// checkout), else the installed one. pub fn apps_dir() -> PathBuf { let mut starts = vec![]; if let Ok(cwd) = std::env::current_dir() { starts.push(cwd); } if let Ok(exe) = std::env::current_exe() { starts.extend(exe.parent().map(Path::to_path_buf)); } for start in starts { for dir in start.ancestors() { let candidate = dir.join("apps"); if candidate.join("settings").join("app.toml").is_file() { return candidate; } } } PathBuf::from("/usr/share/smartfox/apps") }