drinkcat / chroagh

Chromium OS Archlinux Chroot Environment
BSD 3-Clause "New" or "Revised" License
241 stars 27 forks source link

Simple XInput 2 client for use in croutonpowerd and croutonwheel. #18

Closed drinkcat closed 11 years ago

drinkcat commented 11 years ago

Low priority.

This is a simple Xinput 2 client, largely inspired from the existing xinput test-xi2. The main difference is that it listens on the root window, so no need to do tricks to hide the window that xinput test-xi2 creates. xinput is able to do the same now, but this has only been recently merged into the git tree (http://cgit.freedesktop.org/xorg/app/xinput/commit/?id=39ac9d85f464ca3195e8b3b2d3f6c3188f83e25e), so it will probably not appear in distributions anytime soon.

So, we use it for 2 purpose.

  1. In croutonpowerd. Instead of polling xprintidle, we listen for input events (I believe this is completely equivalent: is there anything but input events that would reset the idle time?). This has 2 advantages:
    • With xprintidle, we poll every 2 seconds. That means that once the screen is dimmed after inactivity, it can take up to 2 seconds for the screen to come up again. With croutonxi2event, we react immediately, and the user does not lose precious seconds of productivity after going for a coffee break ,-)
    • xprintidle is an orphan package, no one is maintaining it anymore (the "official" website is not accessible): better not to rely on it...
    • It's a bit tricky to monitor for screensaver status at the same time, but what I wrote works fine. There is a little "limitation" where the system could potentially go to sleep after 4'45" instead of 5', but I don't think it's too serious. The logic to make it sleep after 5'15" is slightly more complicated, and pings the power daemon twice as often, which is why I chose the former.
  2. In croutonwheel:
    • Since we know that the output will be parsed by awk, we print the whole event information on a single line. And we only print relevant events.
    • No need for the hack to hide the xinput window (the hack does not work perfectly: you still see the window for a fraction of a second).
drinkcat commented 11 years ago

??? I'm sending pull requests to myself now?!?!? Brilliant...

dnschneid commented 11 years ago

And you didn't even accept it! How embarrassing.