diff --git a/.changes/info-linux-de-and-session.md b/.changes/info-linux-de-and-session.md new file mode 100644 index 000000000000..024c5f23591b --- /dev/null +++ b/.changes/info-linux-de-and-session.md @@ -0,0 +1,7 @@ +--- +"tauri-cli": "patch:feat" +"@tauri-apps/cli": "patch:feat" +--- + +Include Linux destkop environment and session type in `tauri info` command. + diff --git a/crates/tauri-cli/src/info/env_system.rs b/crates/tauri-cli/src/info/env_system.rs index a0570c28afc6..9deb72844e37 100644 --- a/crates/tauri-cli/src/info/env_system.rs +++ b/crates/tauri-cli/src/info/env_system.rs @@ -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 { 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)]