comand is passed as arg

This commit is contained in:
2025-08-06 02:28:05 +02:00
parent 3d547cd494
commit aa77af36ea

View File

@@ -5,6 +5,8 @@ use egui::{FontData, FontDefinitions, FontFamily};
use std::sync::{Arc, Mutex};
use winit::event_loop::{ControlFlow, EventLoop};
use eframe::UserEvent;
use std::env;
use std::process::Command;
const MAX_KEYS: usize = 6;
const SECRET_COMBO: [Key; MAX_KEYS] = [
@@ -149,6 +151,19 @@ fn setup_custom_fonts(ctx: &egui::Context) {
fn main() {
let mut args = env::args().skip(1); // Skip program name
let admin_command = match args.next() {
Some(cmd) => cmd,
None => {
eprintln!("❌ Usage: sm-admingate <command> [args...]");
std::process::exit(1);
}
};
let admin_args: Vec<String> = args.collect();
let should_run_admin_command = Arc::new(Mutex::new(false));
let shared_flag = should_run_admin_command.clone();
@@ -178,9 +193,8 @@ fn main() {
if *should_run_admin_command.lock().unwrap() {
println!("✅ Running admin command...");
match std::process::Command::new("sh")
.arg("-c")
.arg("kitty")
match std::process::Command::new(admin_command)
.args(admin_args)
.status() // ← wait until it finishes
{
Ok(status) => {