haimgel / display-switch

Turn a $30 USB switch into a full-featured multi-monitor KVM switch
https://haim.dev/posts/2020-07-28-dual-monitor-kvm/
MIT License
2.85k stars 112 forks source link

Support "waking up" monitors on switch under Linux #27

Closed haimgel closed 10 months ago

haimgel commented 3 years ago

The app should wake up the screens when it switches inputs under Linux, the same as it does under Windows and MacOS, e.g. implement wake_displays.

universal commented 3 years ago

notes: https://unix.stackexchange.com/questions/124886/wake-monitor-from-sleep-remotely

xset -display ${DISPLAY} dpms force on appears to be working on ubuntu 20.04

pm215 commented 3 years ago

One potential issue with using 'xset' to trigger wakeup is that it needs the X display, and if you're running display-switch as root from systemd (as per the readme suggestion) then it doesn't have convenient access to the X display.

A possible alternate implementation would be to use /dev/uinput to simulate a USB keyboard or mouse and send a mouse-move or shift-key keypress. This sounds hairy but the implementation is pretty trivial in C (see https://www.kernel.org/doc/html/v4.12/input/uinput.html) and hopefully not too bad in rust (if you're prepared to trust a random crate off crates.rs then it's definitely pretty simple: https://docs.rs/crate/uinput/0.1.3). It would have the neat advantage that it would then not depend on whether you were running X or not.

haimgel commented 3 years ago

@pm215, neat! I'm not too concerned about moving the mouse to wake up screens, this is how this app already does it on Windows, and it works pretty well.

haimgel commented 10 months ago

Implemented in #126