mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
pynput run as user
This commit is contained in:
@@ -243,7 +243,7 @@ pub fn start_os_service() {
|
||||
log::info!("Exit");
|
||||
}
|
||||
|
||||
fn get_active_userid() -> String {
|
||||
pub fn get_active_userid() -> String {
|
||||
get_value_of_seat0(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,16 @@ fn run_cursor(sp: MouseCursorService, state: &mut StateCursor) -> ResultType<()>
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref ENIGO: Arc<Mutex<Enigo>> = Arc::new(Mutex::new(Enigo::new()));
|
||||
static ref ENIGO: Arc<Mutex<Enigo>> = {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if crate::platform::is_root() {
|
||||
std::env::set_var("PYNPUT_USERNAME", crate::platform::linux::get_active_username());
|
||||
std::env::set_var("PYNPUT_USERID", crate::platform::linux::get_active_userid());
|
||||
}
|
||||
}
|
||||
Arc::new(Mutex::new(Enigo::new()))
|
||||
};
|
||||
static ref KEYS_DOWN: Arc<Mutex<HashMap<u64, Instant>>> = Default::default();
|
||||
static ref LATEST_INPUT: Arc<Mutex<Input>> = Default::default();
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ impl Handler {
|
||||
Key::Kp8 => Some(ControlKey::Numpad8),
|
||||
Key::Kp9 => Some(ControlKey::Numpad9),
|
||||
Key::KpDivide => Some(ControlKey::Divide),
|
||||
Key::KpMultiply => Some(ControlKey::Subtract),
|
||||
Key::KpMultiply => Some(ControlKey::Multiply),
|
||||
Key::KpDecimal => Some(ControlKey::Decimal),
|
||||
Key::KpMinus => Some(ControlKey::Subtract),
|
||||
Key::KpPlus => Some(ControlKey::Add),
|
||||
|
||||
Reference in New Issue
Block a user