Gentoo Archives: gentoo-user

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

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Typewriter sound Bill Longman <bill.longman@×××××.com>