From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-user+bounces-113732-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1OlSQO-0001f8-Bf
	for garchives@archives.gentoo.org; Tue, 17 Aug 2010 20:06:22 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id ECA93E0BA5
	for <garchives@archives.gentoo.org>; Tue, 17 Aug 2010 20:06:19 +0000 (UTC)
Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25])
	by pigeon.gentoo.org (Postfix) with ESMTP id 2254FE0AF8
	for <gentoo-user@lists.gentoo.org>; Tue, 17 Aug 2010 19:34:07 +0000 (UTC)
Received: from compute3.internal (compute3.internal [10.202.2.43])
	by gateway1.messagingengine.com (Postfix) with ESMTP id 0297822D
	for <gentoo-user@lists.gentoo.org>; Tue, 17 Aug 2010 15:34:07 -0400 (EDT)
Received: from frontend1.messagingengine.com ([10.202.2.160])
  by compute3.internal (MEProxy); Tue, 17 Aug 2010 15:34:07 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=subject:from:to:in-reply-to:references:content-type:date:message-id:mime-version:content-transfer-encoding; s=smtpout; bh=Zzc/IVGx/sTB4XPMHnKz2popeIE=; b=JiSV+u7fmquJXXR5lC1E0k4ygolymcUst/+Ijy3tiokbBGSiLQz3g0eRPe2J2yEJt3rBVd49mm/bOAnTRAAN718wAbN0w7wJ6Qq4rfT63ijhn/ZZQmQFOQBQbd/GKswRNgFzokr6zZFgiIUiPH9a+azKOwtmLMFD8Ma+NtspFwY=
X-Sasl-enc: e9D0yxPPG6axyN1xDKuNnre5FqhHgHxIoReyDqjB7HB+ 1282073646
Received: from [192.168.0.38] (65.23.112.45.nw.nuvox.net [65.23.112.45])
	by www.fastmail.fm (Postfix) with ESMTPSA id ABD07406EEF
	for <gentoo-user@lists.gentoo.org>; Tue, 17 Aug 2010 15:34:06 -0400 (EDT)
Subject: Re: [gentoo-user] Typewriter sound
From: Albert Hopkins <marduk@letterboxes.org>
To: gentoo-user@lists.gentoo.org
In-Reply-To: <20100817184309.GA9068@solfire>
References: <20100817172005.GA5110@solfire>
	 <1282067763.451766.3.camel@paska> <4C6AD12F.4020007@gmail.com>
	 <20100817184309.GA9068@solfire>
Content-Type: text/plain; charset="UTF-8"
Date: Tue, 17 Aug 2010 15:34:05 -0400
Message-ID: <1282073645.451766.13.camel@paska>
Precedence: bulk
List-Post: <mailto:gentoo-user@lists.gentoo.org>
List-Help: <mailto:gentoo-user+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-user+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-user+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-user.gentoo.org>
X-BeenThere: gentoo-user@lists.gentoo.org
Reply-to: gentoo-user@lists.gentoo.org
Mime-Version: 1.0
X-Mailer: Evolution 2.30.2 
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 9a4112ef-c036-4c45-9261-94a42dbea382
X-Archives-Hash: 1fa84db4f501612aeaa3833cfea2e25d

On Tue, 2010-08-17 at 20:43 +0200, meino.cramer@gmx.de wrote:
> Bill Longman <bill.longman@gmail.com> [10-08-17 20:16]:
> > On 08/17/2010 10:56 AM, Albert Hopkins wrote:
> > > On Tue, 2010-08-17 at 19:20 +0200, meino.cramer@gmx.de wrote:
> > >> Hi,
> > >>
> > >>  on YouTube there was a Blender-2.5 tutorial with audio.=20
> > >>  There was an interesting detail: While there were spoken
> > >>  instructions one can hear one typing on its keyboard.
> > >>  Each hit on one of the keys made the sound of an old
> > >>  typewriter (no, it was not the sound of the legendary
> > >>  "IBM Model M" keyboard ;) ).
> > >>
> > >>  How can I achieve this?
> > >>  What software can I use to make this geeky feature to
> > >>  come true.
> > >>  Unfortunately I have no idea, how to name this kind
> > >>  of what(?) ...
> > >>
> > >>  Thank you very much for any hint in advance!
> > >>  Best regards,
> > >>  mcc
> > >=20
> > > There probably a number of ways to do this.
> > >=20
> > > A cheap and easy way would be to use xev to monitor a window and th=
en
> > > pipe the stderr to a a program that waits for a keypress event and =
then
> > > plays an apropriate.
> > >=20
> > > A less cheap way would be to have our program do what xev does inst=
ead
> > > of using a pipe.
> >=20
> > Or you could set your X keyclick using xset.
> >=20
>=20
> Hi,
>=20
>  thanks a lot for your replies! :)
>  Is there any program already, which does this?
>  A daemon or...<insert missing words here>
>=20
>  Best regards,
>  mcc
>=20
>=20

Well I found out that when you pass window id to xev it does not trap
keyboard presses per-s=C3=A9.  But there is another way...

Anway the following is a quick hack (in python).  It pretty much works
except it also seems to trap mouse presses.  I got the .wav file at
http://www.soundjay.com/typewriter-sounds.html

I tried using 'xset c' but it basically does nothing for me.  My guess
is that it does work it basically sends the a BELL to the console.


--- 8< CUT HERE ---------------------------------------------------
import sys
import subprocess

soundfile =3D 'typewriter-key-1.wav'

def main():
    window_id =3D sys.argv[1]
    cmd =3D ['xev', '-id', window_id]

    p1 =3D subprocess.Popen(cmd, stdout=3Dsubprocess.PIPE)
    while True:
        line =3D p1.stdout.readline()
        if line.find('atom 0x14d') > -1:
            subprocess.Popen(['aplay', soundfile],
stderr=3Dopen('/dev/null',
                'w'))


if __name__ =3D=3D '__main__':
    main()