added a little system resource monitor to the info pane, that shows CPU
usage and RAM usage and refresheds every second.
This commit is contained in:
+14
-1
@@ -1815,7 +1815,7 @@ impl ModuleLoader {
|
||||
std::fs::write(path, contents).is_ok()
|
||||
});
|
||||
engine.register_fn("find_file", |path: PathBuf, filename: String| -> String {
|
||||
for entry in walkdir::WalkDir::new(path).max_depth(10) {
|
||||
for entry in walkdir::WalkDir::new(path).max_depth(50) {
|
||||
if let Ok(entry) = entry {
|
||||
if entry
|
||||
.file_name()
|
||||
@@ -1829,6 +1829,19 @@ impl ModuleLoader {
|
||||
|
||||
String::new()
|
||||
});
|
||||
engine.register_fn("execute", |cmd: &str| -> String {
|
||||
let out_string;
|
||||
if let Ok(output) = Command::new("sh").arg("-c").arg(cmd).output() {
|
||||
if output.status.success() {
|
||||
out_string = format!("[success] {}", String::from_utf8_lossy(&output.stdout));
|
||||
} else {
|
||||
out_string = format!("[error] {}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
} else {
|
||||
out_string = "[error] failed to run command".to_string();
|
||||
}
|
||||
return out_string;
|
||||
});
|
||||
Self {
|
||||
engine: Arc::new(engine),
|
||||
commands: HashMap::new(),
|
||||
|
||||
Reference in New Issue
Block a user