Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 15ecfff82b |
@@ -168,7 +168,7 @@ gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMo
|
|||||||
gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMonitor --method com.soutade.GenericMonitor.deleteGroups '{"groups":["new"]}'
|
gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMonitor --method com.soutade.GenericMonitor.deleteGroups '{"groups":["new"]}'
|
||||||
```
|
```
|
||||||
|
|
||||||
Python examples are available @ https://forge.soutade.fr/soutade/GnomeShellGenericMonitor/src/branch/master/examples
|
Python examples are available @ https://indefero.soutade.fr/p/genericmonitor/source/tree/master/examples
|
||||||
|
|
||||||
|
|
||||||
Development
|
Development
|
||||||
@@ -176,14 +176,6 @@ Development
|
|||||||
|
|
||||||
After doing code update, you can test it within a nested window. In other cases you have to restart GNOME.
|
After doing code update, you can test it within a nested window. In other cases you have to restart GNOME.
|
||||||
|
|
||||||
mutter-dev-bin package is required
|
|
||||||
|
|
||||||
```bash
|
|
||||||
dbus-run-session gnome-shell --devkit --wayland
|
|
||||||
```
|
|
||||||
|
|
||||||
before GNOME 48
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dbus-run-session -- gnome-shell --nested [--wayland]
|
dbus-run-session -- gnome-shell --nested [--wayland]
|
||||||
```
|
```
|
||||||
|
|||||||
+21
-16
@@ -104,7 +104,7 @@ class SignalMgt {
|
|||||||
array.push(id);
|
array.push(id);
|
||||||
id = widget.connect('scroll-event', this._onScroll.bind(this));
|
id = widget.connect('scroll-event', this._onScroll.bind(this));
|
||||||
array.push(id);
|
array.push(id);
|
||||||
id = widget.connect('button-press-event', this._clicked.bind(this));
|
id = widget.connect('button-release-event', this._clicked.bind(this));
|
||||||
array.push(id);
|
array.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,19 +555,31 @@ class MonitorWidget extends PanelMenu.Button {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadInterfaceXml(extension, filename) {
|
// From https://github.com/ubuntu/gnome-shell-extension-appindicator/blob/master/interfaces.js
|
||||||
|
// loads a xml file into an in-memory string
|
||||||
|
function loadInterfaceXml(extension, filename) {
|
||||||
const interfacesDir = extension.dir.get_child('.');
|
const interfacesDir = extension.dir.get_child('.');
|
||||||
|
|
||||||
const file = interfacesDir.get_child(filename);
|
const file = interfacesDir.get_child(filename);
|
||||||
const fd = Gio.File.new_for_path(file.get_path());
|
|
||||||
const [contents, etag] = await fd.load_contents_async(null);
|
|
||||||
|
|
||||||
const decoder = new TextDecoder('utf-8');
|
let [result, contents] = GLib.file_get_contents(file.get_path());
|
||||||
const decoded_content = decoder.decode(contents);
|
|
||||||
|
|
||||||
const res = `<node>${decoded_content}</node>`;
|
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
// HACK: The "" + trick is important as hell because file_get_contents returns
|
||||||
|
// an object (WTF?) but Gio.makeProxyWrapper requires `typeof() == "string"`
|
||||||
|
// Otherwise, it will try to check `instanceof XML` and fail miserably because there
|
||||||
|
// is no `XML` on very recent SpiderMonkey releases (or, if SpiderMonkey is old enough,
|
||||||
|
// will spit out a TypeError soon).
|
||||||
|
if (contents instanceof Uint8Array)
|
||||||
|
{
|
||||||
|
const decoder = new TextDecoder();
|
||||||
|
contents = decoder.decode(contents);
|
||||||
|
}
|
||||||
|
const res = `<node>${contents}</node>`;
|
||||||
return res;
|
return res;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Generic monitor: Could not load file: ${filename}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GenericMonitorDBUS {
|
class GenericMonitorDBUS {
|
||||||
@@ -576,15 +588,9 @@ class GenericMonitorDBUS {
|
|||||||
this.monitor_groups = {};
|
this.monitor_groups = {};
|
||||||
this.actor_clicked = {};
|
this.actor_clicked = {};
|
||||||
this.ClutterSettings = Clutter.Settings.get_default();
|
this.ClutterSettings = Clutter.Settings.get_default();
|
||||||
this._dbusImpl = null;
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(loadInterfaceXml(extension, 'dbus.xml'), this);
|
||||||
loadInterfaceXml(extension, 'dbus.xml')
|
|
||||||
.then( (xml) =>
|
|
||||||
{
|
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(xml, this);
|
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
|
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
|
||||||
this._dbusImpl.emit_signal('onActivate', null);
|
this._dbusImpl.emit_signal('onActivate', null);
|
||||||
})
|
|
||||||
.catch((e) => { this.logger.error(e); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emitSignal(name, value) {
|
emitSignal(name, value) {
|
||||||
@@ -794,7 +800,6 @@ class GenericMonitorDBUS {
|
|||||||
}
|
}
|
||||||
this.monitor_groups = {};
|
this.monitor_groups = {};
|
||||||
this._dbusImpl.unexport();
|
this._dbusImpl.unexport();
|
||||||
this._dbusImpl = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -2,10 +2,9 @@
|
|||||||
"uuid": "generic-monitor@gnome-shell-extensions",
|
"uuid": "generic-monitor@gnome-shell-extensions",
|
||||||
"name": "Generic Monitor",
|
"name": "Generic Monitor",
|
||||||
"description": "Display text & icon on systray using DBUS",
|
"description": "Display text & icon on systray using DBUS",
|
||||||
"version": "21",
|
"version": "19",
|
||||||
"shell-version": [
|
"shell-version": [
|
||||||
"50",
|
"48",
|
||||||
"49"
|
|
||||||
],
|
],
|
||||||
"url": "https://forge.soutade.fr/soutade/GnomeShellGenericMonitor"
|
"url": "https://forge.soutade.fr/soutade/GnomeShellGenericMonitor"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user