Menu
cosmic-mobile
publicLatest change d22956783f74f68f3d7eff1dd31f885aaf0fbe3e - Checkpoint BúiOS prototype and document clean-worktree workflow by AkurAI Build
use std::{
io,
path::{Path, PathBuf},
};
pub fn path() -> PathBuf {
std::env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.unwrap_or_else(|| {
PathBuf::from(std::env::var_os("HOME").expect("HOME missing")).join(".config")
})
.join("cosmic-mobile/navigation")
}
pub fn enabled(path: &Path) -> bool {
std::fs::read_to_string(path).is_ok_and(|s| s.trim() == "buttons")
}
pub fn save(path: &Path, enabled: bool) -> io::Result<()> {
std::fs::create_dir_all(
path.parent()
.ok_or_else(|| io::Error::other("Missing settings directory"))?,
)?;
let temp = path.with_extension("tmp");
std::fs::write(&temp, if enabled { "buttons\n" } else { "gesture\n" })?;
std::fs::rename(temp, path)
}
#[allow(dead_code)]
pub fn button(x: f64, y: f64, width: f64, height: f64) -> Option<usize> {
if x >= 0. && x < width && y >= 0. && y < height {
Some((x * 3. / width) as usize)
} else {
None
}
}