Skip to content

Commit 74212d4

Browse files
authored
feat(cli): include linux DE and session type in tauri info (#11653)
1 parent c3b1fce commit 74212d4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

.changes/info-linux-de-and-session.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-cli": "patch:feat"
3+
"@tauri-apps/cli": "patch:feat"
4+
---
5+
6+
Include Linux destkop environment and session type in `tauri info` command.
7+

crates/tauri-cli/src/info/env_system.rs

+30-2
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,45 @@ fn is_xcode_command_line_tools_installed() -> bool {
175175
.map(|o| o.status.success())
176176
.unwrap_or(false)
177177
}
178+
fn de_and_session() -> String {
179+
#[cfg(any(
180+
target_os = "linux",
181+
target_os = "dragonfly",
182+
target_os = "freebsd",
183+
target_os = "openbsd",
184+
target_os = "netbsd"
185+
))]
186+
return {
187+
let de = std::env::var("DESKTOP_SESSION");
188+
let session = std::env::var("XDG_SESSION_TYPE");
189+
format!(
190+
" ({} on {})",
191+
de.as_deref().unwrap_or("Unknown DE"),
192+
session.as_deref().unwrap_or("Unknown Session")
193+
)
194+
};
195+
196+
#[cfg(not(any(
197+
target_os = "linux",
198+
target_os = "dragonfly",
199+
target_os = "freebsd",
200+
target_os = "openbsd",
201+
target_os = "netbsd"
202+
)))]
203+
String::new()
204+
}
178205

179206
pub fn items() -> Vec<SectionItem> {
180207
vec![
181208
SectionItem::new().action(|| {
182209
let os_info = os_info::get();
183210
format!(
184-
"OS: {} {} {} ({:?})",
211+
"OS: {} {} {} ({:?}){}",
185212
os_info.os_type(),
186213
os_info.version(),
187214
os_info.architecture().unwrap_or("Unknown Architecture"),
188-
os_info.bitness()
215+
os_info.bitness(),
216+
de_and_session(),
189217
).into()
190218
}),
191219
#[cfg(windows)]

0 commit comments

Comments
 (0)