feat: remove autostart as plugin system makes it redundant

This commit is contained in:
Gabriele Musco 2024-12-30 14:39:11 +01:00
commit bd0efe2bcb
4 changed files with 12 additions and 48 deletions

View file

@ -363,7 +363,6 @@ pub struct Profile {
pub lighthouse_driver: LighthouseDriver, pub lighthouse_driver: LighthouseDriver,
#[serde(default = "String::default")] #[serde(default = "String::default")]
pub xrservice_launch_options: String, pub xrservice_launch_options: String,
pub autostart_command: Option<String>,
#[serde(default)] #[serde(default)]
pub skip_dependency_check: bool, pub skip_dependency_check: bool,
} }
@ -422,7 +421,6 @@ impl Default for Profile {
lighthouse_driver: LighthouseDriver::default(), lighthouse_driver: LighthouseDriver::default(),
xrservice_launch_options: String::default(), xrservice_launch_options: String::default(),
uuid, uuid,
autostart_command: None,
skip_dependency_check: false, skip_dependency_check: false,
} }
} }
@ -543,7 +541,6 @@ impl Profile {
mercury_enabled: self.features.mercury_enabled, mercury_enabled: self.features.mercury_enabled,
}, },
environment: self.environment.clone(), environment: self.environment.clone(),
autostart_command: self.autostart_command.clone(),
pull_on_build: self.pull_on_build, pull_on_build: self.pull_on_build,
lighthouse_driver: self.lighthouse_driver, lighthouse_driver: self.lighthouse_driver,
opencomposite_repo: self.opencomposite_repo.clone(), opencomposite_repo: self.opencomposite_repo.clone(),

View file

@ -43,8 +43,7 @@ use crate::{
restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile, restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile,
}, },
util::file_utils::{ util::file_utils::{
mark_as_executable, setcap_cap_sys_nice_eip, setcap_cap_sys_nice_eip_cmd, setcap_cap_sys_nice_eip, setcap_cap_sys_nice_eip_cmd, verify_cap_sys_nice_eip,
verify_cap_sys_nice_eip,
}, },
vulkaninfo::VulkanInfo, vulkaninfo::VulkanInfo,
wivrn_dbus, wivrn_dbus,
@ -80,7 +79,6 @@ pub struct App {
config: Config, config: Config,
xrservice_worker: Option<JobWorker>, xrservice_worker: Option<JobWorker>,
autostart_worker: Option<JobWorker>,
plugins_worker: Option<JobWorker>, plugins_worker: Option<JobWorker>,
restart_xrservice: bool, restart_xrservice: bool,
build_worker: Option<JobWorker>, build_worker: Option<JobWorker>,
@ -103,7 +101,6 @@ pub struct App {
pub enum Msg { pub enum Msg {
OnServiceLog(Vec<String>), OnServiceLog(Vec<String>),
OnServiceExit(i32), OnServiceExit(i32),
OnAutostartExit(i32),
OnPluginsExit(i32), OnPluginsExit(i32),
OnBuildLog(Vec<String>), OnBuildLog(Vec<String>),
OnBuildExit(i32), OnBuildExit(i32),
@ -246,40 +243,23 @@ impl App {
pub fn run_autostart(&mut self, sender: AsyncComponentSender<Self>) { pub fn run_autostart(&mut self, sender: AsyncComponentSender<Self>) {
let prof = self.get_selected_profile(); let prof = self.get_selected_profile();
if let Some(autostart_cmd) = &prof.autostart_command {
let mut jobs = VecDeque::new();
jobs.push_back(WorkerJob::new_cmd(
Some(prof.environment.clone()),
"sh".into(),
Some(vec!["-c".into(), autostart_cmd.clone()]),
));
let autostart_worker = JobWorker::new(jobs, sender.input_sender(), |msg| match msg {
JobWorkerOut::Log(rows) => Msg::OnServiceLog(rows),
JobWorkerOut::Exit(code) => Msg::OnAutostartExit(code),
});
autostart_worker.start();
self.autostart_worker = Some(autostart_worker);
}
let plugins_cmd = self let plugins_cmd = self
.config .config
.plugins .plugins
.values() .values()
.filter_map(|cp| { .filter_map(|cp| {
if cp.enabled && cp.plugin.validate() { if cp.enabled && cp.plugin.validate() {
if let Some(exec) = cp.plugin.executable() { if let Err(e) = cp.plugin.mark_as_executable() {
if let Err(e) = mark_as_executable(&exec) { error!(
error!( "failed to mark plugin {} as executable: {e}",
"failed to mark plugin {} as executable: {e}", cp.plugin.appid
cp.plugin.appid );
);
None
} else {
Some(format!("'{}'", exec.to_string_lossy()))
}
} else {
error!("no executable for plugin {}", cp.plugin.appid);
None None
} else {
Some(format!(
"'{}'",
cp.plugin.executable().unwrap().to_string_lossy()
))
} }
} else { } else {
None None
@ -329,9 +309,6 @@ impl App {
} }
pub fn shutdown_xrservice(&mut self) { pub fn shutdown_xrservice(&mut self) {
if let Some(w) = self.autostart_worker.as_ref() {
w.stop();
}
if let Some(w) = self.plugins_worker.as_ref() { if let Some(w) = self.plugins_worker.as_ref() {
w.stop(); w.stop();
} }
@ -433,7 +410,6 @@ impl AsyncComponent for App {
self.start_xrservice(sender, false); self.start_xrservice(sender, false);
} }
} }
Msg::OnAutostartExit(_) => self.autostart_worker = None,
Msg::OnPluginsExit(_) => self.plugins_worker = None, Msg::OnPluginsExit(_) => self.plugins_worker = None,
Msg::ClockTicking => { Msg::ClockTicking => {
self.main_view.sender().emit(MainViewMsg::ClockTicking); self.main_view.sender().emit(MainViewMsg::ClockTicking);
@ -1039,7 +1015,6 @@ impl AsyncComponent for App {
config, config,
profiles, profiles,
xrservice_worker: None, xrservice_worker: None,
autostart_worker: None,
plugins_worker: None, plugins_worker: None,
build_worker: None, build_worker: None,
xr_devices: vec![], xr_devices: vec![],

View file

@ -50,7 +50,7 @@ impl Plugin {
if let Some(p) = self.executable().as_ref() { if let Some(p) = self.executable().as_ref() {
mark_as_executable(p) mark_as_executable(p)
} else { } else {
bail!("no exec_path for plugin") bail!("no executable found for plugin")
} }
} }

View file

@ -130,14 +130,6 @@ impl SimpleComponent for ProfileEditor {
prof.borrow_mut().prefix = n_path.unwrap_or_default().into(); prof.borrow_mut().prefix = n_path.unwrap_or_default().into();
}), }),
), ),
add: &entry_row("Autostart Command",
model.profile.borrow().autostart_command.as_ref().unwrap_or(&String::default()),
clone!(#[strong] prof, move |row| {
let txt = row.text().trim().to_string();
prof.borrow_mut().autostart_command =
if txt.is_empty() {None} else {Some(txt)};
})
),
add: &switch_row("Dependency Check", add: &switch_row("Dependency Check",
Some("Warning: disabling dependency checks may result in build failures"), Some("Warning: disabling dependency checks may result in build failures"),
!model.profile.borrow().skip_dependency_check, !model.profile.borrow().skip_dependency_check,