File: notifier-example.js

package info (click to toggle)
tinysparql 3.10.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,468 kB
  • sloc: ansic: 118,310; python: 6,139; javascript: 719; sh: 121; perl: 106; xml: 67; makefile: 31; sql: 1
file content (22 lines) | stat: -rwxr-xr-x 560 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/gjs

const { GLib, Gio, Tsparql } = imports.gi

try {
    let connection = Tsparql.SparqlConnection.bus_new(
        'org.freedesktop.Tracker3.Miner.Files',
        null, null);

    let notifier = connection.create_notifier();
    notifier.connect('events', (service, graph, events) => {
        for (let event in events)
            print (`Event ${event.get_event_type()} on ${event.get_urn()}`);
    });

    let loop = GLib.MainLoop.new(null, false);
    loop.run();

    connection.close();
} catch (e) {
    printerr(`Error: ${e.message}`)
}