diff --git a/src/profile.rs b/src/profile.rs index ea299f3..9c8cc86 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -222,6 +222,8 @@ pub struct Profile { #[serde(default = "LighthouseDriver::default")] /** Only applicable for Monado */ pub lighthouse_driver: LighthouseDriver, + #[serde(default = "String::default")] + pub xrservice_launch_options: String, } impl Display for Profile { @@ -250,6 +252,7 @@ impl Default for Profile { opencomposite_repo: None, editable: true, lighthouse_driver: LighthouseDriver::default(), + xrservice_launch_options: String::default(), } } } diff --git a/src/ui/job_worker/internal_worker.rs b/src/ui/job_worker/internal_worker.rs index 4204e60..c7db14d 100644 --- a/src/ui/job_worker/internal_worker.rs +++ b/src/ui/job_worker/internal_worker.rs @@ -151,6 +151,8 @@ impl Worker for InternalJobWorker { } } +const LAUNCH_OPTS_CMD_PLACEHOLDER: &str = "%command%"; + impl InternalJobWorker { pub fn xrservice_worker_from_profile( prof: &Profile, @@ -163,10 +165,28 @@ impl InternalJobWorker { prof.lighthouse_driver.to_string().to_lowercase(), ); } + let launch_opts = prof.xrservice_launch_options.trim(); + let (command, args) = match launch_opts.is_empty() { + false => ( + "sh".into(), + vec![ + "-c".into(), + match launch_opts.contains(LAUNCH_OPTS_CMD_PLACEHOLDER) { + true => launch_opts.replacen( + LAUNCH_OPTS_CMD_PLACEHOLDER, + prof.xrservice_binary().as_str(), + 1, + ), + false => format!("{} {}", prof.xrservice_binary(), launch_opts), + }, + ], + ), + true => (prof.xrservice_binary(), vec![]), + }; let data = CmdWorkerData { environment: env, - command: prof.xrservice_binary(), - args: vec![], + command, + args, }; let mut jobs = VecDeque::new(); jobs.push_back(WorkerJob::Cmd(data)); diff --git a/src/ui/profile_editor.rs b/src/ui/profile_editor.rs index d37c0ac..881eb0f 100644 --- a/src/ui/profile_editor.rs +++ b/src/ui/profile_editor.rs @@ -107,7 +107,13 @@ impl SimpleComponent for ProfileEditor { }, add: xrservicegrp = &adw::PreferencesGroup { set_title: "XR Service", - set_description: Some("When specifying a repository, you can set a specific git ref (branch, tag, commit...) by appending a '#' followed by the ref"), + set_description: Some(concat!( + "When specifying a repository, you can set a ", + "specific git ref (branch, tag, commit...) by ", + "appending a '#' followed by the ref.\n\n", + "For launch options, you can insert %command% as ", + "a placeholder for the actual XR Service command." + )), add: { withclones![prof]; &combo_row( @@ -123,6 +129,16 @@ impl SimpleComponent for ProfileEditor { }, ) }, + add: { + withclones![prof]; + &entry_row( + "XR Service Launch Options", + model.profile.borrow().xrservice_launch_options.as_str(), + move |row| { + prof.borrow_mut().xrservice_launch_options = row.text().trim().to_string(); + } + ) + }, add: { withclones![prof]; &combo_row(