diff --git a/src/profile.rs b/src/profile.rs index 0852c49..4215bbd 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -288,33 +288,42 @@ impl Default for Profile { } impl Profile { + pub fn xr_runtime_json_env_var(&self) -> String { + format!( + "XR_RUNTIME_JSON=\"{prefix}/share/openxr/1/openxr_{runtime}.json\"", + prefix = match self.prefix.as_str() { + SYSTEM_PREFIX => BWRAP_SYSTEM_PREFIX, + other => other, + }, + runtime = match self.xrservice_type { + XRServiceType::Monado => "monado", + XRServiceType::Wivrn => "wivrn", + } + ) + } + + /// always adds the xr runtime json var + pub fn env_vars_full(&self) -> Vec { + vec![ + // format!( + // "VR_OVERRIDE={opencomp}/build", + // opencomp = self.opencomposite_path, + // ), + self.xr_runtime_json_env_var(), + format!( + "PRESSURE_VESSEL_FILESYSTEMS_RW=\"{path}\"", + path = get_ipc_file_path(&self.xrservice_type), + ), + ] + } + pub fn get_env_vars(&self) -> Vec { if self.can_be_built { return vec![ "PRESSURE_VESSEL_FILESYSTEMS_RW=\"$XDG_RUNTIME_DIR/wivrn_comp_ipc:$XDG_RUNTIME_DIR/monado_comp_ipc\"".into(), ]; } - vec![ - // format!( - // "VR_OVERRIDE={opencomp}/build", - // opencomp = self.opencomposite_path, - // ), - format!( - "XR_RUNTIME_JSON=\"{prefix}/share/openxr/1/openxr_{runtime}.json\"", - prefix = match self.prefix.as_str() { - SYSTEM_PREFIX => BWRAP_SYSTEM_PREFIX, - other => other, - }, - runtime = match self.xrservice_type { - XRServiceType::Monado => "monado", - XRServiceType::Wivrn => "wivrn", - } - ), - format!( - "PRESSURE_VESSEL_FILESYSTEMS_RW=\"{path}\"", - path = get_ipc_file_path(&self.xrservice_type), - ), - ] + self.env_vars_full() } pub fn get_steam_launch_options(&self) -> String { diff --git a/src/ui/app.rs b/src/ui/app.rs index 421a022..416b413 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -130,6 +130,7 @@ pub enum Msg { Quit, DebugOpenPrefix, DebugOpenData, + DebugCopyEnvVars, OpenWivrnConfig, HandleCommandLine(CmdLineOpts), } @@ -684,6 +685,9 @@ impl SimpleComponent for App { self.get_selected_profile().prefix )); } + Msg::DebugCopyEnvVars => { + copy_text(&self.get_selected_profile().env_vars_full().join(" ")); + } Msg::OpenWivrnConfig => { let editor = WivrnConfEditor::builder() .launch(WivrnConfEditorInit { @@ -845,6 +849,13 @@ impl SimpleComponent for App { sender.input(Msg::DebugOpenPrefix); }) ); + stateless_action!( + actions, + DebugCopyEnvVarsAction, + clone!(@strong sender => move |_| { + sender.input(Msg::DebugCopyEnvVars); + }) + ); actions.add_action(RelmAction::::new_stateful( &model.enable_debug_view, clone!(@strong sender => move |_, state| { @@ -891,3 +902,4 @@ new_stateful_action!(pub DebugViewToggleAction, AppActionGroup, "debugviewtoggle new_stateless_action!(pub DebugOpenDataAction, AppActionGroup, "debugopendata"); new_stateless_action!(pub DebugOpenPrefixAction, AppActionGroup, "debugopenprefix"); +new_stateless_action!(pub DebugCopyEnvVarsAction, AppActionGroup, "debugcopyenvvars"); diff --git a/src/ui/debug_view.rs b/src/ui/debug_view.rs index 08f64d1..c6a7060 100644 --- a/src/ui/debug_view.rs +++ b/src/ui/debug_view.rs @@ -1,7 +1,7 @@ use super::term_widget::TermWidget; use crate::log_level::LogLevel; use crate::log_parser::MonadoLog; -use crate::ui::app::{DebugOpenDataAction, DebugOpenPrefixAction}; +use crate::ui::app::{DebugCopyEnvVarsAction, DebugOpenDataAction, DebugOpenPrefixAction}; use crate::ui::util::copy_text; use gtk::glib::clone; use gtk::prelude::*; @@ -59,6 +59,7 @@ impl SimpleComponent for DebugView { section! { "Open _Data Folder" => DebugOpenDataAction, "Open _Prefix Folder" => DebugOpenPrefixAction, + "Copy Profile _Environment Variables" => DebugCopyEnvVarsAction, }, } }