mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 03:24:52 +00:00
feat: xrservice launch options
This commit is contained in:
parent
4b58b6c2d8
commit
5c31c1ba67
3 changed files with 42 additions and 3 deletions
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue