#!/usr/local/bin/gjs-console -m

import GLib from "gi://GLib";
import { exit } from "system";

imports.package.init({
  name: "org.gnome.Decibels",
  version: "49.6.1",
  prefix: "/usr/local",
  libdir: "/usr/local/lib",
  datadir: "/usr/local/share",
});

pkg.initGettext();
pkg.initFormat();

const loop = new GLib.MainLoop(null, false);
import("resource:///org/gnome/Decibels/js/main.js")
  .then((main) => {
    GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
      loop.quit();
      const exitCode = imports.package.run(main);
      exit(exitCode);
      return GLib.SOURCE_REMOVE;
    });
  })
  .catch(logError);
loop.run();
