1 |
Albert Hopkins <marduk@×××××××××××.org> [10-08-18 04:16]: |
2 |
> On Tue, 2010-08-17 at 19:41 -0400, Albert Hopkins wrote: |
3 |
> > Here is my edit of his Python script. |
4 |
> |
5 |
> ... which I actually forgot to attach :| |
6 |
> |
7 |
> -a |
8 |
> |
9 |
|
10 |
> #!/usr/bin/env python |
11 |
> ## A tiny, nifty script for playing musical notes on each keypress. |
12 |
> ## |
13 |
> ## Copyright Sayan "Riju" Chakrabarti (sayanriju) 2009 |
14 |
> ## me[at]sayanriju[dot]co[dot]cc ## |
15 |
> ## Released under WTFPL Version 2 |
16 |
> ## (DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE) |
17 |
> ## Copy of license text can be found online at ## http://sam.zoy.org/wtfpl/COPYING |
18 |
> ## http://rants.sayanriju.co.cc/script-to-make-tick-tick-sound-on-keypress |
19 |
> |
20 |
> from Xlib.display import Display |
21 |
> import subprocess |
22 |
> import time |
23 |
> |
24 |
> KEYPRESSFILE = 'typewriter-key-1.wav' |
25 |
> RETURNFILE = 'typewriter-line-break-1.wav' |
26 |
> |
27 |
> notes=[440,494,523,587,659,698,784] |
28 |
> |
29 |
> ZERO,SHIFT,ALT,CTL=[],[],[],[] |
30 |
> ENTER = [0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
31 |
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
32 |
> for i in range(0,32): |
33 |
> ZERO.append(0) |
34 |
> if i==6: |
35 |
> SHIFT.append(4) |
36 |
> else: |
37 |
> SHIFT.append(0) |
38 |
> if i==4: |
39 |
> CTL.append(32) |
40 |
> else: |
41 |
> CTL.append(0) |
42 |
> if i==8: |
43 |
> ALT.append(1) |
44 |
> else: |
45 |
> ALT.append(0) |
46 |
> |
47 |
> ignorelist=[ZERO,ALT,SHIFT,CTL] |
48 |
> |
49 |
> def main(): |
50 |
> disp = Display() # connect to display |
51 |
> |
52 |
> while 1: #event loop |
53 |
> keymap = disp.query_keymap() |
54 |
> if keymap not in ignorelist: |
55 |
> filename = RETURNFILE if keymap == ENTER else KEYPRESSFILE |
56 |
> subprocess.Popen(['aplay', filename], stderr=open('/dev/null', |
57 |
> 'w')) |
58 |
> time.sleep(0.1) |
59 |
> |
60 |
> |
61 |
> if __name__ == '__main__': |
62 |
> main() |
63 |
|
64 |
Hi, |
65 |
|
66 |
I checked the script -- it works :) |
67 |
But it is to slow (my computer is to slow, I am too fast?) |
68 |
I can press twice the number of keys which got "sounded" by |
69 |
the script. |
70 |
Or is something wrong with the setup of my sound interface? |
71 |
My computer is a Athlon XP2 64 (32 bit Gentoo) 3800+, so I |
72 |
think, that it is not /that/ slow :) |
73 |
Any ideas? |
74 |
Best regards, |
75 |
mcc |