aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorHenil Dedania <dedaniahenil@gmail.com>2021-01-21 12:04:29 +0530
committerGitHub <noreply@github.com>2021-01-21 12:04:29 +0530
commitc32b837df772cbfb53ccd3b5434aefcbe7aaaf0b (patch)
treebf74330c49e1f230a2693632a1db2c94a6309f6e /src/main.rs
parentfix(main): do not hang on exit (#150) (diff)
downloadsl0ppij-c32b837df772cbfb53ccd3b5434aefcbe7aaaf0b.tar.gz
sl0ppij-c32b837df772cbfb53ccd3b5434aefcbe7aaaf0b.tar.xz
sl0ppij-c32b837df772cbfb53ccd3b5434aefcbe7aaaf0b.zip
feat(plugin): Search in root folder for plugins and layout files
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index a913de16..dd6f91af 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,7 @@ mod wasm_vm;
use std::io::Write;
use std::os::unix::net::UnixStream;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::sync::mpsc::{channel, sync_channel, Receiver, SendError, Sender, SyncSender};
use std::thread;
use std::{cell::RefCell, sync::mpsc::TrySendError};
@@ -44,6 +44,7 @@ use crate::layout::Layout;
use crate::os_input_output::{get_os_input, OsApi};
use crate::pty_bus::{PtyBus, PtyInstruction, VteEvent};
use crate::screen::{Screen, ScreenInstruction};
+use crate::utils::consts::MOSAIC_ROOT_PLUGIN_DIR;
use crate::utils::{
consts::{MOSAIC_IPC_PIPE, MOSAIC_TMP_DIR, MOSAIC_TMP_LOG_DIR},
logging::*,
@@ -452,9 +453,13 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let project_dirs =
ProjectDirs::from("org", "Mosaic Contributors", "Mosaic").unwrap();
let plugin_dir = project_dirs.data_dir().join("plugins/");
+ let root_plugin_dir = Path::new(MOSAIC_ROOT_PLUGIN_DIR);
let wasm_bytes = fs::read(&path)
.or_else(|_| fs::read(&path.with_extension("wasm")))
.or_else(|_| fs::read(&plugin_dir.join(&path).with_extension("wasm")))
+ .or_else(|_| {
+ fs::read(&root_plugin_dir.join(&path).with_extension("wasm"))
+ })
.unwrap_or_else(|_| panic!("cannot find plugin {}", &path.display()));
// FIXME: Cache this compiled module on disk. I could use `(de)serialize_to_file()` for that