Skip to content

Commit e896cce

Browse files
authored
Merge pull request #29 from nekename/main
fix: improve Flatpak detection code to avoid Distrobox false positives
2 parents 7cc36cc + 8dd9596 commit e896cce

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/sys.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ pub struct SystemProperties {
2727
pub engine_version: String,
2828
}
2929

30+
#[cfg(target_os = "linux")]
31+
fn is_flatpak() -> bool {
32+
use std::env::var;
33+
var("FLATPAK_ID").is_ok()
34+
|| var("container")
35+
.map(|x| x.to_lowercase().trim() == "flatpak")
36+
.unwrap_or(false)
37+
}
38+
3039
pub fn get_info() -> SystemProperties {
3140
let info = os_info::get();
3241
let locale = sys_locale::get_locale().unwrap_or_default();
@@ -35,7 +44,8 @@ pub fn get_info() -> SystemProperties {
3544
let os_name = match info.os_type() {
3645
os_info::Type::Macos => "macOS".to_string(),
3746
os_info::Type::Windows => "Windows".to_string(),
38-
_ if std::env::var("container").is_ok() => "Flatpak".to_string(),
47+
#[cfg(target_os = "linux")]
48+
_ if is_flatpak() => "Flatpak".to_string(),
3949
_ => info.os_type().to_string(),
4050
};
4151

0 commit comments

Comments
 (0)