changed themes directory to $XDG_DATA_HOME and config directory to $XDG_CONFIG_HOME

This commit is contained in:
Emma Tebibyte 2023-04-15 16:20:07 -04:00
parent 5aed7766c9
commit a3ba320016
1 changed files with 13 additions and 4 deletions

View File

@ -46,11 +46,19 @@ impl Default for Config {
/// Gets the configuration directory. Panics if unavailable.
pub fn get_config_dir() -> PathBuf {
std::env::var_os("HOME")
std::env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::try_from)
.expect("$HOME is unset")
.expect("$XDG_CONFIG_HOME is unset")
.unwrap()
.join(".config/breed")
.join("breed")
}
pub fn get_data_dir() -> PathBuf {
std::env::var_os("XDG_DATA_HOME")
.map(PathBuf::try_from)
.expect("$XDG_DATA_HOME is unset")
.unwrap()
.join("breed")
}
/// Watches a theme file and automatically reloads it into a [StyleStore].
@ -65,7 +73,8 @@ pub struct ThemeWatcher {
impl ThemeWatcher {
pub fn spawn(styles: Arc<Mutex<StyleStore>>) -> Sender<PathBuf> {
let themes_dir = get_config_dir().join("themes");
let themes_dir = get_data_dir().join("themes");
println!("{:?}", themes_dir);
let default_path = themes_dir.join("default.toml");
let (fs_tx, fs_rx) = unbounded();
let (command_tx, command_rx) = unbounded();