Skip to content

Instantly share code, notes, and snippets.

@shimarin
Created Apr 11, 2012
Embed
What would you like to do?
ビープ音を鳴らす誰得Pythonスクリプト。リモートからビープ音を鳴らしてそこにいる人をびっくりさせるの禁止
#!/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