Skip to content

Instantly share code, notes, and snippets.

@ToQoz
Created October 23, 2012 06:47
Show Gist options
  • Save ToQoz/3937292 to your computer and use it in GitHub Desktop.
Save ToQoz/3937292 to your computer and use it in GitHub Desktop.
音.rb
require "mac-event-monitor"
monitor = Mac::EventMonitor::Monitor.new
monitor.add_listener(:key_down) do |event|
system("afplay #{ENV['HOME']}/bin/sounds/#{event.keycode % 14 + 1}.wav &")
end
monitor.add_listener(:mouse_move) do |event|
system("afplay #{ENV['HOME']}/bin/sounds/#{rand(14) + 1}.wav &")
end
monitor.run
# 1. install
# $ gem install mac-event-monitor
#
# 2. sound
# ~/sounds/1.wav 〜 ~/sounds/14.wav を用意
# https://dl.dropbox.com/u/5978869/music/sounds.zip
#
# 3. boot
# $ ruby 音.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment