Merge branch 'main' into iidev

This commit is contained in:
Byson94
2025-10-13 19:26:22 +05:30
3 changed files with 16 additions and 4 deletions

View File

@@ -30,6 +30,7 @@ use tokio::sync::watch;
pub fn handle_listen(
var_name: String,
props: &Map,
shell: String,
store: ReactiveVarStore,
tx: tokio::sync::mpsc::UnboundedSender<String>,
) {
@@ -76,7 +77,7 @@ pub fn handle_listen(
tokio::spawn(async move {
let mut child = unsafe {
Command::new("/bin/sh")
Command::new(&shell)
.arg("-c")
.arg(&cmd)
// .kill_on_drop(true)

View File

@@ -25,6 +25,7 @@ use std::sync::Mutex;
use std::{collections::HashMap, sync::Arc, sync::RwLock};
use tokio::sync::mpsc::UnboundedSender;
use tokio::sync::watch;
use std::process::Command;
pub type ReactiveVarStore = Arc<RwLock<HashMap<String, String>>>;
pub static SHUTDOWN_REGISTRY: Lazy<Mutex<Vec<watch::Sender<bool>>>> =
@@ -35,14 +36,23 @@ pub fn handle_state_changes(
tx: UnboundedSender<String>,
store: ReactiveVarStore,
) {
// Check Dash and prefer if dash is installed.
let dash_installed: bool = Command::new("which")
.arg("dash")
.output()
.map(|o| o.status.success())
.unwrap_or(false);
let shell = if dash_installed { String::from("/bin/dash") } else { String::from("/bin/sh") };
if let WidgetNode::Enter(children) = root_node {
for child in children {
match child {
WidgetNode::Poll { var, props } => {
handle_poll(var.to_string(), props, store.clone(), tx.clone());
handle_poll(var.to_string(), props, shell.clone(), store.clone(), tx.clone());
}
WidgetNode::Listen { var, props } => {
handle_listen(var.to_string(), props, store.clone(), tx.clone());
handle_listen(var.to_string(), props, shell.clone(), store.clone(), tx.clone());
}
_ => {}
}

View File

@@ -26,6 +26,7 @@ use tokio::time::sleep;
pub fn handle_poll(
var_name: String,
props: &Map,
shell: String,
store: ReactiveVarStore,
tx: tokio::sync::mpsc::UnboundedSender<String>,
) {
@@ -57,7 +58,7 @@ pub fn handle_poll(
tokio::spawn(async move {
// Spawn a persistent shell
let mut child = match Command::new("/bin/sh")
let mut child = match Command::new(&shell)
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn()