mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-02-16 02:20:43 +00:00
Merge pull request #440 from fufesou/fix/linux_is_kde
fix: linux is_kde()
This commit is contained in:
@@ -85,6 +85,8 @@ fn find_cmd_path(cmd: &'static str) -> String {
|
|||||||
cmd.to_string()
|
cmd.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated. Use `hbb_common::platform::linux::is_kde_session()` instead for now.
|
||||||
|
// Or we need to set the correct environment variable in the server process.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_kde() -> bool {
|
pub fn is_kde() -> bool {
|
||||||
if let Ok(env) = std::env::var(XDG_CURRENT_DESKTOP) {
|
if let Ok(env) = std::env::var(XDG_CURRENT_DESKTOP) {
|
||||||
@@ -94,6 +96,18 @@ pub fn is_kde() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't use `hbb_common::platform::linux::is_kde()` here.
|
||||||
|
// It's not correct in the server process.
|
||||||
|
pub fn is_kde_session() -> bool {
|
||||||
|
std::process::Command::new(CMD_SH.as_str())
|
||||||
|
.arg("-c")
|
||||||
|
.arg("pgrep -f kded[0-9]+")
|
||||||
|
.stdout(std::process::Stdio::piped())
|
||||||
|
.output()
|
||||||
|
.map(|o| !o.stdout.is_empty())
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_gdm_user(username: &str) -> bool {
|
pub fn is_gdm_user(username: &str) -> bool {
|
||||||
username == "gdm" || username == "sddm"
|
username == "gdm" || username == "sddm"
|
||||||
|
|||||||
Reference in New Issue
Block a user