master/bin/inotify_watch

25 lines
458 B
Plaintext
Raw Normal View History

2010-10-03 21:00:33 +00:00
#!/usr/bin/env ruby
require 'rubygems'
require 'rb-inotify'
folders = Array.new
notifier = INotify::Notifier.new
notifier.watch(ARGV.first || '.', :modify, :recursive) do |event|
dir = File.expand_path(File.dirname(event.absolute_name)) + '/'
if !folders.include?(dir)
folders << dir
end
end
while true do
notifier.process
if !folders.empty?
$stdout.puts folders.join(' ')
$stdout.flush
folders.clear
end
sleep(0.1)
end