Skip to content

Commit

Permalink
Move mouse instead of keyboard input
Browse files Browse the repository at this point in the history
  • Loading branch information
haimgel committed Oct 22, 2023
1 parent af0d63b commit cdc5ad1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUST_BACKTRACE: full

jobs:
build:
Expand Down
14 changes: 7 additions & 7 deletions src/platform/wake_displays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ pub fn wake_displays() -> Result<()> {
use std::{thread, time};
use uinput::{Device, event::keyboard};

fn make_kbd_device() -> Result<Device> {
Ok(uinput::default()?
let mut device = uinput::default()?
.name("display-switch")?
.event(uinput::event::Keyboard::All)?
.create()?)
}
.mouse(uinput::event::mouse::Relative::X)?
.create()?;

let mut device = make_kbd_device().context("Couldn't wake displays: couldn't configure uinput")?;

// This sleep appears to be necessary based on testing.
// Possibly X does not immediately recognize the new device?
thread::sleep(time::Duration::from_secs(1));

device.click(&keyboard::Key::RightAlt)?;
device.send(uinput::event::mouse::relative::X(-1))?;
device.synchronize()?;
thread::sleep(time::Duration::from_millis(50));
device.send(uinput::event::mouse::relative::X(1))?;
device.synchronize()?;
Ok(())
}
Expand Down

0 comments on commit cdc5ad1

Please sign in to comment.