-
-
Save nkoep/b7f07350d860678ad763 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GLib = imports.gi.GLib; | |
const Gio = imports.gi.Gio; | |
const Lang = imports.lang; | |
const BUS_NAME = "org.freedesktop.Notifications"; | |
const OBJECT_PATH = "/" + BUS_NAME.replace(/\./g, "\/"); | |
const NotificationDaemonIface = <interface name="org.freedesktop.Notifications"> | |
<method name="Notify"> | |
<arg type="s" direction="in"/> | |
<arg type="u" direction="in"/> | |
<arg type="s" direction="in"/> | |
<arg type="s" direction="in"/> | |
<arg type="s" direction="in"/> | |
<arg type="as" direction="in"/> | |
<arg type="a{sv}" direction="in"/> | |
<arg type="i" direction="in"/> | |
<arg type="u" direction="out"/> | |
</method> | |
</interface>; | |
function BusName() { | |
this._init(); | |
} | |
BusName.prototype = { | |
_init: function() { | |
var owner_id = Gio.bus_own_name( | |
Gio.BusType.SESSION, // bus | |
BUS_NAME, // bus name | |
Gio.BusNameOwnerFlags.REPLACE, // owner flags | |
null, // bus_acquired_cb | |
Lang.bind(this, function(connection, name, userdata) { | |
print("Acquired bus name: " + name); | |
print("Exporting object: " + OBJECT_PATH); | |
this._export_object(); | |
}), // name_acquired_cb | |
null, // name_lost_cb | |
null // userdata | |
); | |
}, | |
_export_object: function() { | |
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject( | |
NotificationDaemonIface, this); | |
this._dbusImpl.export(Gio.DBus.session, OBJECT_PATH); | |
} | |
}; | |
function main() { | |
var bus_name = new BusName(); | |
var main_loop = new GLib.MainLoop(null, 0); | |
main_loop.run(); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment