Skip to content

Instantly share code, notes, and snippets.

@shimarin
Created April 11, 2012 11:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shimarin/2358720 to your computer and use it in GitHub Desktop.
Save shimarin/2358720 to your computer and use it in GitHub Desktop.
ビープ音を鳴らす誰得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