mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-08 10:35:43 +00:00
feat: preemtpively remove ipc file on xr service start
This commit is contained in:
parent
0e6028b0db
commit
637bac2ae3
3 changed files with 22 additions and 12 deletions
13
src/paths.rs
13
src/paths.rs
|
@ -1,4 +1,4 @@
|
||||||
use crate::constants::CMD_NAME;
|
use crate::{constants::CMD_NAME, profile::XRServiceType};
|
||||||
use std::{env, fs::create_dir_all, path::Path};
|
use std::{env, fs::create_dir_all, path::Path};
|
||||||
|
|
||||||
pub fn data_opencomposite_path() -> String {
|
pub fn data_opencomposite_path() -> String {
|
||||||
|
@ -106,3 +106,14 @@ pub fn get_exec_prefix() -> String {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_ipc_file_path(xrservice_type: &XRServiceType) -> String {
|
||||||
|
format!(
|
||||||
|
"{runtime}/{xrservice}_comp_ipc",
|
||||||
|
runtime=get_xdg_runtime_dir(),
|
||||||
|
xrservice = match xrservice_type {
|
||||||
|
XRServiceType::Monado => "monado",
|
||||||
|
XRServiceType::Wivrn => "wivrn",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
file_utils::get_writer,
|
file_utils::get_writer,
|
||||||
paths::{
|
paths::{
|
||||||
data_monado_path, data_opencomposite_path, get_data_dir, BWRAP_SYSTEM_PREFIX, SYSTEM_PREFIX,
|
data_monado_path, data_opencomposite_path, get_data_dir, BWRAP_SYSTEM_PREFIX, SYSTEM_PREFIX, get_ipc_file_path,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -259,13 +259,7 @@ impl Profile {
|
||||||
XRServiceType::Wivrn => "wivrn",
|
XRServiceType::Wivrn => "wivrn",
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
format!(
|
get_ipc_file_path(&self.xrservice_type),
|
||||||
"PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/{xrservice}_comp_ipc",
|
|
||||||
xrservice = match self.xrservice_type {
|
|
||||||
XRServiceType::Monado => "monado",
|
|
||||||
XRServiceType::Wivrn => "wivrn",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"%command%".into(),
|
"%command%".into(),
|
||||||
]
|
]
|
||||||
.join(" ")
|
.join(" ")
|
||||||
|
|
|
@ -28,6 +28,7 @@ use crate::file_builders::openvrpaths_vrpath::{
|
||||||
};
|
};
|
||||||
use crate::file_utils::setcap_cap_sys_nice_eip;
|
use crate::file_utils::setcap_cap_sys_nice_eip;
|
||||||
use crate::log_parser::MonadoLog;
|
use crate::log_parser::MonadoLog;
|
||||||
|
use crate::paths::get_ipc_file_path;
|
||||||
use crate::profile::{Profile, XRServiceType};
|
use crate::profile::{Profile, XRServiceType};
|
||||||
use crate::profiles::lighthouse::lighthouse_profile;
|
use crate::profiles::lighthouse::lighthouse_profile;
|
||||||
use crate::profiles::system_valve_index::system_valve_index_profile;
|
use crate::profiles::system_valve_index::system_valve_index_profile;
|
||||||
|
@ -48,6 +49,7 @@ use relm4::adw::ResponseAppearance;
|
||||||
use relm4::gtk::glib;
|
use relm4::gtk::glib;
|
||||||
use relm4::{new_action_group, new_stateful_action, new_stateless_action, prelude::*};
|
use relm4::{new_action_group, new_stateful_action, new_stateless_action, prelude::*};
|
||||||
use relm4::{ComponentParts, ComponentSender, SimpleComponent};
|
use relm4::{ComponentParts, ComponentSender, SimpleComponent};
|
||||||
|
use std::fs::remove_file;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[tracker::track]
|
#[tracker::track]
|
||||||
|
@ -147,6 +149,9 @@ impl App {
|
||||||
};
|
};
|
||||||
self.debug_view.sender().emit(DebugViewMsg::ClearLog);
|
self.debug_view.sender().emit(DebugViewMsg::ClearLog);
|
||||||
self.xr_devices = XRDevices::default();
|
self.xr_devices = XRDevices::default();
|
||||||
|
remove_file(&get_ipc_file_path(&prof.xrservice_type))
|
||||||
|
.is_err()
|
||||||
|
.then(|| println!("Failed to remove xrservice IPC file"));
|
||||||
let mut runner = CmdRunner::xrservice_runner_from_profile(&prof);
|
let mut runner = CmdRunner::xrservice_runner_from_profile(&prof);
|
||||||
match runner.try_start() {
|
match runner.try_start() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -342,9 +347,9 @@ impl SimpleComponent for App {
|
||||||
None => {}
|
None => {}
|
||||||
Some(devices) => {
|
Some(devices) => {
|
||||||
self.xr_devices.merge(devices.clone());
|
self.xr_devices.merge(devices.clone());
|
||||||
self.main_view
|
self.main_view.sender().emit(MainViewMsg::UpdateDevices(
|
||||||
.sender()
|
Some(self.xr_devices.clone()),
|
||||||
.emit(MainViewMsg::UpdateDevices(Some(self.xr_devices.clone())));
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue