#!/usr/bin/env python

# Andrew Clunis <aclunis@infoglobe.ca>

# Stupid userspace workaround for intel-hda breakage in kernels (at least)
# 2.6.20 to 2.6.22 on the ThinkPad T61.  Breakage in the driver causes all
# audio out to be permanently muted.

# I noticed, however, that I could hear perhaps 250 ms worth of music
# whenever the PC speaker was sounded (although, conveniently, not the tone
# itself).

# Just run this program as root and your speakers (but not microphone or 
# earphone jacks) will magically work.

KIOCSOUND = 0x4B2F

import fcntl, sys

import time

# Do a constant beep.
# Reset the beep every five seconds, in case it is cleared by another program.
while(True):
    fd = open("/dev/console")
    fcntl.ioctl(fd, KIOCSOUND, 500)
    fd.close()
    time.sleep(5)

