Created
April 11, 2012 11:24
-
-
Save shimarin/2358720 to your computer and use it in GitHub Desktop.
ビープ音を鳴らす誰得Pythonスクリプト。リモートからビープ音を鳴らしてそこにいる人をびっくりさせるの禁止
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import fcntl | |
import time | |
KIOCSOUND = 0x4B2F | |
CLOCK_TICK_RATE = 1193180 | |
def beep(hz, len): | |
fd = os.open("/dev/console", os.O_WRONLY) | |
try: | |
fcntl.ioctl(fd, KIOCSOUND, CLOCK_TICK_RATE / hz) | |
try: | |
time.sleep(len) | |
finally: | |
fcntl.ioctl(fd, KIOCSOUND, 0) | |
finally: | |
os.close(fd) | |
if __name__ == '__main__': | |
beep(440, 0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment