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 ) id 1Qymw3-0004tk-CD for garchives@archives.gentoo.org; Wed, 31 Aug 2011 15:42:39 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C5BBE21C100; Wed, 31 Aug 2011 15:42:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7103721C099 for ; Wed, 31 Aug 2011 15:41:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 000351B4016 for ; Wed, 31 Aug 2011 15:41:28 +0000 (UTC) X-Virus-Scanned: by amavisd-new using ClamAV at gentoo.org X-Spam-Score: -5.316 X-Spam-Level: X-Spam-Status: No, score=-5.316 required=5.5 tests=[AWL=1.283, BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4] Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9AAJjZC1fIG0 for ; Wed, 31 Aug 2011 15:41:22 +0000 (UTC) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by smtp.gentoo.org (Postfix) with ESMTP id 420F964223 for ; Wed, 31 Aug 2011 15:41:18 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Qymui-0006QC-Ir for gentoo-user@gentoo.org; Wed, 31 Aug 2011 17:41:16 +0200 Received: from dsl.comtrol.com ([64.122.56.22]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Aug 2011 17:41:16 +0200 Received: from grant.b.edwards by dsl.comtrol.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Aug 2011 17:41:16 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-user@lists.gentoo.org From: Grant Edwards Subject: [gentoo-user] Re: Typewriter sound Date: Wed, 31 Aug 2011 15:41:02 +0000 (UTC) Message-ID: References: <20100817172005.GA5110@solfire> <1282067763.451766.3.camel@paska> <4C6AD12F.4020007@gmail.com> <20100817184309.GA9068@solfire> <1282073645.451766.13.camel@paska> <4E5E50C2.30900@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: dsl.comtrol.com User-Agent: slrn/pre0.9.9-102 (Linux) X-Archives-Salt: X-Archives-Hash: f3d0b7ece054bb87fd9686d127f40f72 On 2011-08-31, Space Cake wrote: >>>>> A cheap and easy way would be to use xev to monitor a window and then >>>>> pipe the stderr to a a program that waits for a keypress event and >>>>> then plays an apropriate. Thats how I did it in Python: ------------------------------------------------------------------------ #!/usr/bin/python import sys import subprocess soundfile = 'typewriter-key-1.wav' def main(): window_id = sys.argv[1] cmd = ['xev', '-id', window_id] p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE) while True: line = p1.stdout.readline() if line.find('KeyPress event') > -1: subprocess.Popen(['aplay', soundfile],stderr=open('/dev/null','w')) if __name__ == '__main__': main() ---------------------------------------------------------------------- I don't remember where I got the typewriter-key-1.wav file from. It's amusing for about 30 seconds.... ;) -- Grant Edwards grant.b.edwards Yow! FUN is never having to at say you're SUSHI!! gmail.com