mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
linux_wayland_support: dup detecting function of x11 or wayland
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -74,7 +74,7 @@ pub use macos::Enigo;
|
||||
#[cfg(target_os = "linux")]
|
||||
mod linux;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use crate::linux::{is_x11, Enigo};
|
||||
pub use crate::linux::Enigo;
|
||||
|
||||
/// DSL parser module
|
||||
pub mod dsl;
|
||||
|
||||
@@ -3,35 +3,3 @@ mod pynput;
|
||||
mod xdo;
|
||||
|
||||
pub use self::nix_impl::Enigo;
|
||||
|
||||
/// Check if display manager is x11.
|
||||
pub fn is_x11() -> bool {
|
||||
let stdout =
|
||||
match std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg("loginctl show-session $(loginctl | awk '/tty/ {print $1}') -p Type | awk -F= '{print $2}'")
|
||||
.output() {
|
||||
Ok(output) => {
|
||||
output.stdout
|
||||
},
|
||||
Err(_) => {
|
||||
match std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg("echo $XDG_SESSION_TYPE")
|
||||
.output() {
|
||||
Ok(output) => {
|
||||
output.stdout
|
||||
},
|
||||
Err(_) => {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if let Ok(display_manager) = std::str::from_utf8(&stdout) {
|
||||
display_manager.trim() == "x11"
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Enigo {
|
||||
impl Default for Enigo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
is_x11: crate::linux::is_x11(),
|
||||
is_x11: "x11" == hbb_common::platform::linux::get_display_server(),
|
||||
uinput_keyboard: None,
|
||||
uinput_mouse: None,
|
||||
xdo: EnigoXdo::default(),
|
||||
|
||||
Reference in New Issue
Block a user