This repository has been archived on 2023-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
gnome-extension-evil-eval/extension.js
2022-09-23 21:11:57 +02:00

41 lines
No EOL
987 B
JavaScript

/*
* Example: clearing messages
*
* gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/EvilEval * --method org.gnome.Shell.Extensions.EvilEval.Eval "Main.panel.statusArea.dateMenu._messageList.* _sectionList.get_children().forEach(s => s.clear());"
*
*/
const { Gio } = imports.gi;
const Main = imports.ui.main;
const DBUS_INTERFACE = `
<node>
<interface name="org.gnome.Shell.Extensions.EvilEval">
<method name="Eval">
<arg type="s" direction="in" name="code"/>
</method>
</interface>
</node>`;
class Extension {
enable() {
this._dbus = Gio.DBusExportedObject.wrapJSObject(DBUS_INTERFACE, this);
this._dbus.export(Gio.DBus.session, '/org/gnome/Shell/Extensions/EvilEval');
}
disable() {
this._dbus.flush();
this._dbus.unexport();
delete this._dbus;
}
Eval(code) {
eval(code);
}
}
function init() {
return new Extension();
}