aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-02-16 17:23:16 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-02-16 17:23:16 +0000
commit5a3caba55f4d90e7e58fe797b805fb610e0de9c4 (patch)
tree0889514af166dec69faad91eb2ca76496f124aab /src
parentfeat(input): new keybindings and persistent mode as default (#181) (diff)
downloadsl0ppij-5a3caba55f4d90e7e58fe797b805fb610e0de9c4.tar.gz
sl0ppij-5a3caba55f4d90e7e58fe797b805fb610e0de9c4.tar.xz
sl0ppij-5a3caba55f4d90e7e58fe797b805fb610e0de9c4.zip
Install assets on first run
Diffstat (limited to 'src')
-rw-r--r--src/common/install.rs12
-rw-r--r--src/common/mod.rs1
-rw-r--r--src/main.rs21
3 files changed, 33 insertions, 1 deletions
diff --git a/src/common/install.rs b/src/common/install.rs
new file mode 100644
index 00000000..cd00aa1f
--- /dev/null
+++ b/src/common/install.rs
@@ -0,0 +1,12 @@
+#[macro_export]
+macro_rules! asset_map {
+ ($($path:literal),+) => {
+ {
+ let mut assets = std::collections::HashMap::new();
+ $(
+ assets.insert($path, include_bytes!(concat!("../assets/", $path)).to_vec());
+ )+
+ assets
+ }
+ }
+} \ No newline at end of file
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 00ee64fd..a256e3ef 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -2,6 +2,7 @@ pub mod command_is_executing;
pub mod errors;
pub mod input;
pub mod ipc;
+pub mod install;
pub mod os_input_output;
pub mod pty_bus;
pub mod screen;
diff --git a/src/main.rs b/src/main.rs
index 50c0b6f3..5c9a70ea 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,8 +11,9 @@ use common::{
command_is_executing, errors, os_input_output, pty_bus, screen, start, utils, wasm_vm,
ApiCommand,
};
+use directories_next::ProjectDirs;
-use std::io::Write;
+use std::{fs, io::Write};
use std::os::unix::net::UnixStream;
use structopt::StructOpt;
@@ -27,6 +28,24 @@ use crate::utils::{
};
pub fn main() {
+ // First run installation of default plugins & layouts
+ let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
+ let data_dir = project_dirs.data_dir();
+ let assets = asset_map!{
+ "plugins/status-bar.wasm",
+ "plugins/strider.wasm",
+ "layouts/default.yaml",
+ "layouts/strider.yaml"
+ };
+
+ for (path, bytes) in assets {
+ let path = data_dir.join(path);
+ fs::create_dir_all(path.parent().unwrap()).unwrap();
+ if !path.exists() {
+ fs::write(path, bytes).expect("Failed to install default assets!");
+ }
+ }
+
let opts = CliArgs::from_args();
if let Some(split_dir) = opts.split {
match split_dir {