title: Reading stdout from xinput test in python
body: <p>I am trying to stream the output of xinput into my python program, however my program just waits and stays blank. I think it may have something to do with buffering but I cannot say. Running <code>xinput test 15</code> gives me my mouse movements, but doing this will not print it. By the way, to find out your mouseid just type <code>xinput</code> and it will list your devices.</p>
  
  <pre><code>#!/usr/bin/env python
  import sys
  import subprocess
  
  
  # connect to mouse
  g = subprocess.Popen(["xinput", "test", str(mouse_id)], stdout=subprocess.PIPE)
  
  for line in g.stdout:
      print(line)
      sys.stdout.flush()    
  </code></pre>