feat(cli): include linux DE and session type in tauri info (#11653)

This commit is contained in:
Amr Bashir
2024-11-12 15:59:47 +02:00
committed by GitHub
parent c3b1fced38
commit 74212d40d8
2 changed files with 37 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
---
"tauri-cli": "patch:feat"
"@tauri-apps/cli": "patch:feat"
---
Include Linux destkop environment and session type in `tauri info` command.

View File

@@ -175,17 +175,45 @@ fn is_xcode_command_line_tools_installed() -> bool {
.map(|o| o.status.success())
.unwrap_or(false)
}
fn de_and_session() -> String {
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd"
))]
return {
let de = std::env::var("DESKTOP_SESSION");
let session = std::env::var("XDG_SESSION_TYPE");
format!(
" ({} on {})",
de.as_deref().unwrap_or("Unknown DE"),
session.as_deref().unwrap_or("Unknown Session")
)
};
#[cfg(not(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd"
)))]
String::new()
}
pub fn items() -> Vec<SectionItem> {
vec![
SectionItem::new().action(|| {
let os_info = os_info::get();
format!(
"OS: {} {} {} ({:?})",
"OS: {} {} {} ({:?}){}",
os_info.os_type(),
os_info.version(),
os_info.architecture().unwrap_or("Unknown Architecture"),
os_info.bitness()
os_info.bitness(),
de_and_session(),
).into()
}),
#[cfg(windows)]