mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Load schemes from $XDG_STATE/yazi/schemes.toml
Signed-off-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
parent
cfe35cc691
commit
64cede1fed
1 changed files with 8 additions and 5 deletions
|
|
@ -3,8 +3,6 @@ use std::collections::HashMap;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
use crate::MERGED_YAZI;
|
|
||||||
|
|
||||||
/// Schemes in configuration file.
|
/// Schemes in configuration file.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Schemes {
|
pub struct Schemes {
|
||||||
|
|
@ -12,7 +10,12 @@ pub struct Schemes {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Schemes {
|
impl Default for Schemes {
|
||||||
fn default() -> Self { toml::from_str(&MERGED_YAZI).unwrap() }
|
fn default() -> Self {
|
||||||
|
let schemes_path = yazi_shared::Xdg::state_dir().join("schemes.toml");
|
||||||
|
// Ignore any errors, as it's fine to have an empty file.
|
||||||
|
let schemes_content = std::fs::read_to_string(&schemes_path).unwrap_or_default();
|
||||||
|
toml::from_str(&schemes_content).unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Schemes {
|
impl Schemes {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue