From cc157862fbcfb8282889a730b285d4d1dde788bd Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Sat, 17 Jun 2023 22:50:18 +0200 Subject: [PATCH] feat: bwrap path for system profiles for XR_RUNTIME_JSON --- src/paths.rs | 5 +++++ src/profile.rs | 7 +++++-- src/profiles/system_valve_index.rs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/paths.rs b/src/paths.rs index 5d90072..f916f6e 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -11,3 +11,8 @@ pub fn data_monado_path() -> String { pub fn data_libsurvive_path() -> String { format!("{data}/libsurvive", data = get_data_dir()) } + +pub const SYSTEM_PREFIX: &str = "/usr"; + +/** System prefix inside a bubblewrap environment (flatpak or pressure vessel) */ +pub const BWRAP_SYSTEM_PREFIX: &str = "/run/host/usr"; diff --git a/src/profile.rs b/src/profile.rs index 786b942..45e6984 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -1,4 +1,4 @@ -use crate::file_utils::get_writer; +use crate::{file_utils::get_writer, paths::{SYSTEM_PREFIX, BWRAP_SYSTEM_PREFIX}}; use expect_dialog::ExpectDialog; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, fmt::Display, fs::File, io::BufReader}; @@ -31,7 +31,10 @@ impl Profile { let mut opts = vec![]; opts.push(format!( "XR_RUNTIME_JSON={prefix}/share/openxr/1/openxr_monado.json", - prefix = self.prefix + prefix = match self.prefix.as_str() { + SYSTEM_PREFIX => BWRAP_SYSTEM_PREFIX, + other => other, + } )); opts.push(format!( "PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc" diff --git a/src/profiles/system_valve_index.rs b/src/profiles/system_valve_index.rs index 5a12a88..1e6eb08 100644 --- a/src/profiles/system_valve_index.rs +++ b/src/profiles/system_valve_index.rs @@ -1,4 +1,4 @@ -use crate::{constants::APP_NAME, paths::data_opencomposite_path, profile::Profile}; +use crate::{constants::APP_NAME, paths::{data_opencomposite_path, SYSTEM_PREFIX}, profile::Profile}; use std::collections::HashMap; pub fn system_valve_index_profile() -> Profile { @@ -18,7 +18,7 @@ pub fn system_valve_index_profile() -> Profile { mercury_enabled: false, basalt_enabled: false, environment, - prefix: "/usr".into(), + prefix: SYSTEM_PREFIX.into(), can_be_built: false, } }