title: Detecting if computer is idle based on mouse and keyboard interactions
body: <p>I'm am writing a piece of software in C++ that controls the keyboard backlight on my MacBook Pro which runs Arch Linux as main OS and Debian for funzies. The program runs as a daemon and is as of now able to turn the keyboard backlight on. Next step is to make it keep an eye on when the computer is idle (based on mouse and keyboard interactions) and when it has been idle for some time, turn off the backlight, and as soon an interaction with keyboard or mouse is registered, turn the backlight on again.</p>
  
  <p>I have googled around, but I havent found anything I could get working to check when the last mouse and/or keyboard interaction was registered.</p>
  
  <p>Any idea to how I can achieve this?
  I believe there already exists such capabilities in some part of any Linux OS (maybe X?) so using this would be preferable instead of writing from scratch.</p>
  
  <p>Regards,...</p>