#include <gio/gio.h>
#include <glib.h>

// gcc -o inotify-test inotify-test.c \
//   `pkg-config --libs --cflags glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0`

static void
changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file,
            GFileMonitorEvent event_type, gpointer user_data)
{
  g_print ("changed.\n");
}

int main()
{
  GMainLoop *loop;
  GFile *f;
  GFileMonitor *mon;
  GError *error = NULL;
  gchar *path = "/tmp/subdir1/subdir2/file";

  g_type_init ();

  f = g_file_new_for_path (path);
  mon = g_file_monitor (f, G_FILE_MONITOR_NONE, NULL, &error);

  g_object_connect (mon, "signal::changed", changed_cb, NULL, NULL);

  loop = g_main_loop_new (NULL, TRUE);
  g_main_loop_run (loop);

  return 0;
}

