From 7e2a585b0f68469bd24c81133f6ee3aea8e21b5c Mon Sep 17 00:00:00 2001 From: GabMus Date: Sat, 20 Jul 2024 10:20:18 +0000 Subject: [PATCH] feat: show warning for wivrn profiles inside appimage --- src/is_appimage.rs | 11 +++++++++++ src/main.rs | 1 + src/ui/app.rs | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/is_appimage.rs diff --git a/src/is_appimage.rs b/src/is_appimage.rs new file mode 100644 index 0000000..d039ace --- /dev/null +++ b/src/is_appimage.rs @@ -0,0 +1,11 @@ +use std::env; + +use lazy_static::lazy_static; + +fn is_appimage() -> bool { + env::var("APPIMAGE").is_ok_and(|s| !s.trim().is_empty()) +} + +lazy_static! { + pub static ref IS_APPIMAGE: bool = is_appimage(); +} diff --git a/src/main.rs b/src/main.rs index a4498a9..6859e7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ pub mod file_builders; pub mod file_utils; pub mod func_runner; pub mod gpu_profile; +pub mod is_appimage; pub mod linux_distro; pub mod log_level; pub mod log_parser; diff --git a/src/ui/app.rs b/src/ui/app.rs index 416b413..57fe10f 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -33,6 +33,7 @@ use crate::file_builders::openvrpaths_vrpath::{ set_current_openvrpaths_to_profile, set_current_openvrpaths_to_steam, }; use crate::file_utils::setcap_cap_sys_nice_eip; +use crate::is_appimage::IS_APPIMAGE; use crate::linux_distro::LinuxDistro; use crate::paths::{get_data_dir, get_ipc_file_path}; use crate::profile::{Profile, XRServiceType}; @@ -105,6 +106,9 @@ pub struct App { #[tracker::do_not_track] skip_depcheck: bool, + + #[tracker::do_not_track] + wivrn_appimage_warn_shown: bool, } #[derive(Debug)] @@ -647,6 +651,17 @@ impl SimpleComponent for App { } } Msg::ProfileSelected(prof) => { + if *IS_APPIMAGE + && !self.wivrn_appimage_warn_shown + && prof.xrservice_type == XRServiceType::Wivrn + { + alert( + "Envision is running as an AppImage", + Some("WiVRn does not support running inside an AppImage, and is likely to fail. You might want to install Envision using a different method."), + Some(&self.app_win.clone().upcast()), + ); + self.wivrn_appimage_warn_shown = true; + } if prof.uuid == self.config.selected_profile_uuid { return; } @@ -803,6 +818,7 @@ impl SimpleComponent for App { libmonado: None, wivrn_conf_editor: None, skip_depcheck: false, + wivrn_appimage_warn_shown: false, }; let widgets = view_output!();