public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-user] Re: Typewriter sound
  @ 2011-08-31 15:41 99%           ` Grant Edwards
  0 siblings, 0 replies; 1+ results
From: Grant Edwards @ 2011-08-31 15:41 UTC (permalink / raw
  To: gentoo-user

On 2011-08-31, Space Cake <spacecakex@gmail.com> 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            




^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2010-08-17 17:20     [gentoo-user] Typewriter sound meino.cramer
2010-08-17 17:56     ` Albert Hopkins
2010-08-17 18:13       ` Bill Longman
2010-08-17 18:43         ` meino.cramer
2010-08-17 19:34           ` Albert Hopkins
2011-08-31 15:18             ` Space Cake
2011-08-31 15:41 99%           ` [gentoo-user] " Grant Edwards

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox