Gentoo Archives: gentoo-user

From: Albert Hopkins <marduk@×××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Typewriter sound
Date: Tue, 17 Aug 2010 20:06:22
Message-Id: 1282073645.451766.13.camel@paska
In Reply to: Re: [gentoo-user] Typewriter sound by meino.cramer@gmx.de
1 On Tue, 2010-08-17 at 20:43 +0200, meino.cramer@×××.de wrote:
2 > Bill Longman <bill.longman@×××××.com> [10-08-17 20:16]:
3 > > On 08/17/2010 10:56 AM, Albert Hopkins wrote:
4 > > > On Tue, 2010-08-17 at 19:20 +0200, meino.cramer@×××.de wrote:
5 > > >> Hi,
6 > > >>
7 > > >> on YouTube there was a Blender-2.5 tutorial with audio.
8 > > >> There was an interesting detail: While there were spoken
9 > > >> instructions one can hear one typing on its keyboard.
10 > > >> Each hit on one of the keys made the sound of an old
11 > > >> typewriter (no, it was not the sound of the legendary
12 > > >> "IBM Model M" keyboard ;) ).
13 > > >>
14 > > >> How can I achieve this?
15 > > >> What software can I use to make this geeky feature to
16 > > >> come true.
17 > > >> Unfortunately I have no idea, how to name this kind
18 > > >> of what(?) ...
19 > > >>
20 > > >> Thank you very much for any hint in advance!
21 > > >> Best regards,
22 > > >> mcc
23 > > >
24 > > > There probably a number of ways to do this.
25 > > >
26 > > > A cheap and easy way would be to use xev to monitor a window and then
27 > > > pipe the stderr to a a program that waits for a keypress event and then
28 > > > plays an apropriate.
29 > > >
30 > > > A less cheap way would be to have our program do what xev does instead
31 > > > of using a pipe.
32 > >
33 > > Or you could set your X keyclick using xset.
34 > >
35 >
36 > Hi,
37 >
38 > thanks a lot for your replies! :)
39 > Is there any program already, which does this?
40 > A daemon or...<insert missing words here>
41 >
42 > Best regards,
43 > mcc
44 >
45 >
46
47 Well I found out that when you pass window id to xev it does not trap
48 keyboard presses per-sé. But there is another way...
49
50 Anway the following is a quick hack (in python). It pretty much works
51 except it also seems to trap mouse presses. I got the .wav file at
52 http://www.soundjay.com/typewriter-sounds.html
53
54 I tried using 'xset c' but it basically does nothing for me. My guess
55 is that it does work it basically sends the a BELL to the console.
56
57
58 --- 8< CUT HERE ---------------------------------------------------
59 import sys
60 import subprocess
61
62 soundfile = 'typewriter-key-1.wav'
63
64 def main():
65 window_id = sys.argv[1]
66 cmd = ['xev', '-id', window_id]
67
68 p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE)
69 while True:
70 line = p1.stdout.readline()
71 if line.find('atom 0x14d') > -1:
72 subprocess.Popen(['aplay', soundfile],
73 stderr=open('/dev/null',
74 'w'))
75
76
77 if __name__ == '__main__':
78 main()

Replies

Subject Author
Re: [gentoo-user] Typewriter sound Mick <michaelkintzios@×××××.com>
Re: [gentoo-user] Typewriter sound Space Cake <spacecakex@×××××.com>