diff --git a/src/lib.rs b/src/lib.rs index 4f4e5f83..542162eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,11 +81,8 @@ impl State { warn!(?err, "Failed to setup cosmic-session communication"); } - let mut args = env::args().skip(1); - self.common.kiosk_child = if let Some(exec) = args.next() { + self.common.kiosk_child = if let Some(mut command) = self.kiosk_command.take() { // Run command in kiosk mode - let mut command = process::Command::new(&exec); - command.args(args); command.envs( session::get_env(&self.common).expect("WAYLAND_DISPLAY should be valid UTF-8"), ); @@ -96,7 +93,7 @@ impl State { }) }; - info!("Running {:?}", exec); + info!("Running {:?}", command.get_program()); command .spawn() .map_err(|err| { @@ -115,8 +112,10 @@ impl State { pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box> { let raw_args = RawArgs::from_args(); let mut cursor = raw_args.cursor(); + raw_args.next_os(&mut cursor); let git_hash = option_env!("GIT_HASH").unwrap_or("unknown"); + let mut kiosk_command = None; let mut with_xwayland = true; // Parse the arguments while let Some(arg) = raw_args.next_os(&mut cursor) { @@ -137,7 +136,11 @@ pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box> { ); return Ok(()); } - _ => {} + _ => { + let mut cmd = process::Command::new(arg); + cmd.args(raw_args.remaining(&mut cursor)); + kiosk_command = Some(cmd); + } } } @@ -171,6 +174,7 @@ pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box> { event_loop.handle(), event_loop.get_signal(), with_xwayland, + kiosk_command, ); // init backend backend::init_backend_auto(&display, &mut event_loop, &mut state)?; diff --git a/src/state.rs b/src/state.rs index cf66aeaa..bef2c0ba 100644 --- a/src/state.rs +++ b/src/state.rs @@ -127,7 +127,7 @@ use std::{ cmp::min, collections::HashSet, ffi::OsString, - process::Child, + process::{Child, Command}, sync::{Arc, LazyLock, Once, atomic::AtomicBool}, time::{Duration, Instant}, }; @@ -225,6 +225,7 @@ pub struct State { pub common: Common, pub ready: Once, pub last_refresh: LastRefresh, + pub kiosk_command: Option, } smithay::delegate_dispatch2!(State); @@ -633,6 +634,7 @@ impl State { handle: LoopHandle<'static, State>, signal: LoopSignal, with_xwayland: bool, + kiosk_command: Option, ) -> State { let requested_languages = DesktopLanguageRequester::requested_languages(); i18n_embed::select(&*LANG_LOADER, &Localizations, &requested_languages) @@ -810,6 +812,7 @@ impl State { backend: BackendData::Unset, ready: Once::new(), last_refresh: LastRefresh::None, + kiosk_command, } }