public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Albert Hopkins <marduk@letterboxes.org>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Typewriter sound
Date: Tue, 17 Aug 2010 19:44:12 -0400	[thread overview]
Message-ID: <1282088652.456104.21.camel@paska> (raw)
In-Reply-To: <1282088517.456104.20.camel@paska>

[-- Attachment #1: Type: text/plain, Size: 145 bytes --]

On Tue, 2010-08-17 at 19:41 -0400, Albert Hopkins wrote:
> Here is my edit of his Python script. 

... which I actually forgot to attach :|

-a


[-- Attachment #2: keypress.py --]
[-- Type: text/x-python, Size: 1444 bytes --]

#!/usr/bin/env python
## A tiny, nifty script for playing musical notes on each keypress.
##
##  Copyright Sayan "Riju" Chakrabarti (sayanriju) 2009
##  me[at]sayanriju[dot]co[dot]cc ##
##      Released under WTFPL Version 2
## (DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE)
##  Copy of license text can be found online at ##      http://sam.zoy.org/wtfpl/COPYING
## http://rants.sayanriju.co.cc/script-to-make-tick-tick-sound-on-keypress

from Xlib.display import Display
import subprocess
import time

KEYPRESSFILE = 'typewriter-key-1.wav'
RETURNFILE = 'typewriter-line-break-1.wav'

notes=[440,494,523,587,659,698,784]

ZERO,SHIFT,ALT,CTL=[],[],[],[]
ENTER = [0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(0,32):
    ZERO.append(0)
    if i==6:
        SHIFT.append(4)
    else:
        SHIFT.append(0)
    if i==4:
        CTL.append(32)
    else:
        CTL.append(0)
    if i==8:
        ALT.append(1)
    else:
        ALT.append(0)

ignorelist=[ZERO,ALT,SHIFT,CTL]

def main():
    disp = Display()    # connect to display

    while 1:    #event loop
        keymap = disp.query_keymap()
        if keymap not in ignorelist:
            filename = RETURNFILE if keymap == ENTER else KEYPRESSFILE
            subprocess.Popen(['aplay', filename], stderr=open('/dev/null',
                'w'))
            time.sleep(0.1)


if __name__ == '__main__':
    main()

  reply	other threads:[~2010-08-18  0:09 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2010-08-17 21:44         ` Mick
2010-08-17 23:11           ` Bill Longman
2011-08-31 15:18         ` Space Cake
2011-08-31 15:41           ` [gentoo-user] " Grant Edwards
2011-08-31 15:54           ` [gentoo-user] " Volker Armin Hemmann
2011-08-31 16:20             ` Space Cake
2011-08-31 16:27             ` [gentoo-user] " Grant Edwards
2011-08-31 16:49               ` Paul Hartman
2011-08-31 17:46                 ` Grant Edwards
2011-08-31 18:50                   ` Paul Hartman
2011-08-31 20:18                     ` Grant Edwards
2011-08-31 21:58                       ` Paul Hartman
2011-09-01  0:57                         ` Grant Edwards
2011-09-01  2:43                           ` Paul Hartman
2011-09-01 13:53                             ` Grant Edwards
2011-09-01 14:22                           ` Frank Steinmetzger
2011-09-01 18:58                             ` Mick
2011-09-01 16:36                           ` Volker Armin Hemmann
2011-09-01 19:11                             ` Grant Edwards
2011-09-04 12:55                       ` Alex Schuster
2010-08-17 22:14 ` [gentoo-user] " Paul Hartman
2010-08-17 22:47   ` meino.cramer
2010-08-18  3:42     ` Paul Hartman
2010-08-18  3:53       ` Dale
2010-08-18 13:45         ` [gentoo-user] " Grant Edwards
2010-08-18 15:56       ` [gentoo-user] " meino.cramer
2010-08-17 23:17   ` Albert Hopkins
2010-08-17 23:41     ` Albert Hopkins
2010-08-17 23:44       ` Albert Hopkins [this message]
2010-08-18 14:14         ` Stefan G. Weichinger
2010-08-18 15:10           ` Peter Ruskin
2010-08-18 16:46             ` Stefan G. Weichinger
2010-08-18 16:20         ` meino.cramer
2010-08-18 16:43           ` Albert Hopkins
2010-08-18 16:06   ` meino.cramer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282088652.456104.21.camel@paska \
    --to=marduk@letterboxes.org \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox