1 |
On 2011. aug. 31., szerda, 17.54.15 CEST, Volker Armin Hemmann wrote: |
2 |
> Am Mittwoch 31 August 2011, 17:18:26 schrieb Space Cake: |
3 |
>> 2010-08-17 21:34 keltezéssel, Albert Hopkins írta: |
4 |
>>> On Tue, 2010-08-17 at 20:43 +0200, meino.cramer@×××.de wrote: |
5 |
>>>> Bill Longman <bill.longman@×××××.com> [10-08-17 20:16]: |
6 |
>>>>> On 08/17/2010 10:56 AM, Albert Hopkins wrote: |
7 |
>>>>>> On Tue, 2010-08-17 at 19:20 +0200, meino.cramer@×××.de |
8 |
>>>>>> |
9 |
>>>>>> wrote: |
10 |
>>>>>>> Hi, |
11 |
>>>>>>> |
12 |
>>>>>>> on YouTube there was a Blender-2.5 tutorial with audio. |
13 |
>>>>>>> There was an interesting detail: While there were spoken |
14 |
>>>>>>> instructions one can hear one typing on its keyboard. Each |
15 |
>>>>>>> hit on one of the keys made the sound of an old typewriter |
16 |
>>>>>>> (no, it was not the sound of the legendary "IBM Model M" |
17 |
>>>>>>> keyboard ;) ). |
18 |
>>>>>>> |
19 |
>>>>>>> How can I achieve this? What software can I use to make |
20 |
>>>>>>> this geeky feature to come true. Unfortunately I have no |
21 |
>>>>>>> idea, how to name this kind of what(?) ... |
22 |
>>>>>>> |
23 |
>>>>>>> Thank you very much for any hint in advance! Best regards, |
24 |
>>>>>>> mcc |
25 |
>>>>>> |
26 |
>>>>>> There probably a number of ways to do this. |
27 |
>>>>>> |
28 |
>>>>>> A cheap and easy way would be to use xev to monitor a window |
29 |
>>>>>> and then pipe the stderr to a a program that waits for a |
30 |
>>>>>> keypress event and then plays an apropriate. |
31 |
>>>>>> |
32 |
>>>>>> A less cheap way would be to have our program do what xev |
33 |
>>>>>> does instead of using a pipe. |
34 |
>>>>> |
35 |
>>>>> Or you could set your X keyclick using xset. |
36 |
>>>> |
37 |
>>>> Hi, |
38 |
>>>> |
39 |
>>>> thanks a lot for your replies! :) Is there any program already, |
40 |
>>>> which does this? A daemon or...<insert missing words here> |
41 |
>>>> |
42 |
>>>> Best regards, mcc |
43 |
>>> |
44 |
>>> Well I found out that when you pass window id to xev it does not |
45 |
>>> trap keyboard presses per-sé. But there is another way... |
46 |
>>> |
47 |
>>> Anway the following is a quick hack (in python). It pretty much |
48 |
>>> works except it also seems to trap mouse presses. I got the .wav |
49 |
>>> file at http://www.soundjay.com/typewriter-sounds.html |
50 |
>>> |
51 |
>>> I tried using 'xset c' but it basically does nothing for me. My |
52 |
>>> guess is that it does work it basically sends the a BELL to the |
53 |
>>> console. |
54 |
>>> |
55 |
>>> |
56 |
>>> --- 8< CUT HERE |
57 |
>>> --------------------------------------------------- import sys |
58 |
>>> import subprocess |
59 |
>>> |
60 |
>>> soundfile = 'typewriter-key-1.wav' |
61 |
>>> |
62 |
>>> def main(): window_id = sys.argv[1] cmd = ['xev', '-id', |
63 |
>>> window_id] |
64 |
>>> |
65 |
>>> p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE) while True: line |
66 |
>>> = p1.stdout.readline() if line.find('atom 0x14d') > -1: |
67 |
>>> subprocess.Popen(['aplay', soundfile], stderr=open('/dev/null', |
68 |
>>> 'w')) |
69 |
>>> |
70 |
>>> |
71 |
>>> if __name__ == '__main__': main() |
72 |
>> |
73 |
>> Guys, this is awesome :) Let's make an ebuild and put in portage :) |
74 |
>> |
75 |
>> L: |
76 |
> |
77 |
> why? |
78 |
> man xset |
79 |
> |
80 |
> really guys. Why do it the long, hard and stupid way if there have been |
81 |
> simple, built in solutions for longer than some of you live? |
82 |
|
83 |
I can't achieve the same with xset :) but this solution is working very |
84 |
well, this is a really important project showing the power of |
85 |
opensource :) |
86 |
|
87 |
L: |