feat: show warning for wivrn profiles inside appimage

This commit is contained in:
GabMus 2024-07-20 10:20:18 +00:00
commit 7e2a585b0f
3 changed files with 28 additions and 0 deletions

11
src/is_appimage.rs Normal file
View file

@ -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();
}

View file

@ -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;

View file

@ -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!();