Skip to content

Commit

Permalink
plugins: Load /usr/lib/reset by default (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM authored Jun 6, 2024
1 parent 7a5ae06 commit c1e418b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pub static mut CONFIG_STRING: Lazy<String> = Lazy::new(|| {
String::from("")
}
});
#[allow(clippy::declare_interior_mutable_const)]
pub const CONFIG: Lazy<Table> = Lazy::new(parse_config);
pub static CONFIG: Lazy<Table> = Lazy::new(parse_config);

pub fn parse_config() -> Table {
unsafe {
Expand Down
15 changes: 11 additions & 4 deletions src/utils/plugin_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static SETUP_LIBS: fn() = || {
}
LIBS_LOADING.store(true, std::sync::atomic::Ordering::SeqCst);
let read_dir: fn(PathBuf) = |dir: PathBuf| {
let binding = CONFIG;
let plugins = binding.get("plugins");
let plugins = CONFIG.get("plugins");
if plugins.is_none() {
LOG!("No plugins entry found in config");
return;
Expand All @@ -69,7 +68,13 @@ static SETUP_LIBS: fn() = || {
return;
}
let plugins = plugins.unwrap();
let plugin_dir = dir.read_dir().expect("Could not read directory");
let plugin_dir = dir.read_dir();
if plugin_dir.is_err() {
// do not print error to ignore the usr/lib if not needed
dbg!("lib not exist brudi");
return;
}
let plugin_dir = plugin_dir.unwrap();
plugin_dir.for_each(|plugin| {
if let Ok(file) = plugin {
if !plugins.contains(&Value::String(String::from(
Expand Down Expand Up @@ -114,8 +119,10 @@ static SETUP_LIBS: fn() = || {
unsafe {
if PLUGIN_DIR.is_dir() {
read_dir(PLUGIN_DIR.clone());
read_dir(PathBuf::from("/usr/lib/reset/"));
} else if let Some(plugin_dir) = plugin_dir {
read_dir(plugin_dir)
read_dir(plugin_dir);
read_dir(PathBuf::from("/usr/lib/reset/"));
}
}
LIBS_LOADED.store(true, std::sync::atomic::Ordering::SeqCst);
Expand Down

0 comments on commit c1e418b

Please sign in to comment.