Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] Typewriter sound Space Cake <spacecakex@×××××.com>
[gentoo-user] Re: Typewriter sound Grant Edwards <grant.b.edwards@×××××.com>