master/bin/inotify_watch
Thibaud Guillaume-Gentil 4d3744ff43 Initial commit
2010-10-03 23:00:33 +02:00

25 lines
458 B
Ruby
Executable File

#!/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