Skip to content

Commit

Permalink
feat(cli): include linux DE and session type in tauri info (#11653)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored Nov 12, 2024
1 parent c3b1fce commit 74212d4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changes/info-linux-de-and-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-cli": "patch:feat"
"@tauri-apps/cli": "patch:feat"
---

Include Linux destkop environment and session type in `tauri info` command.

32 changes: 30 additions & 2 deletions crates/tauri-cli/src/info/env_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 74212d4

Please sign in to comment.