Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using synclient to track the position of finger on the touchpad. I use the following command.

synclient -m 100 | awk '{print $2,$3}'

This command gives the 'x' and 'y' co-ordinate on the touch-pad.
What I want is, to give these co-ordinates to program which will draw these points. As soon as new point is tracked, it should be drawn. But my problem is, since the command generate the output continuously and it has not yet finished, I don't know how to pass the continuous generating output of a command. How to achieve this?

(What I have achieved is the following:

timeout 5 synclient -m 100 > pattern 

So after 5 seconds, 'pattern' file has all the information, I extract the co-ordinates from the file and the draw the lines. But I don't want to do this.)

share|improve this question
    
I doubt whether bash shell programs (as the author has tagged the question) are suited for plotting graphs. I feel this is best suited for stackoverflow. –  Naai Sekar May 6 '13 at 4:29
    
i am going to pass the co-ordinates to a python script. –  Sagar Rakshe May 6 '13 at 5:54

1 Answer 1

up vote 1 down vote accepted

I assume that each line shall result in a new drawing. So something like

synclient -m 100 |
  while read _ x y; do
    drawprogram $x $y
  done

should do. If you get buffering problems then have a look at stdbuf.

share|improve this answer
    
Thanks, work done!! –  Sagar Rakshe May 6 '13 at 7:06
    
@SagarRakshe Shouldn't you accept (and upvote) the answer then...? –  Hauke Laging May 6 '13 at 8:17
    
not yet eligible to upvote! will surely upvote when eligible! –  Sagar Rakshe May 6 '13 at 12:26
    
@SagarRakshe you can still accept (click on the tick mark to the left of this answer), that way the question is marked as answered. –  terdon May 6 '13 at 12:30
1  
@HaukeLaging could you explain what the _ does please? –  terdon May 6 '13 at 12:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.