1 Commits

Author SHA1 Message Date
soutade 15ecfff82b Update metadata.json 2025-11-23 11:52:36 +01:00
3 changed files with 29 additions and 33 deletions
+1 -9
View File
@@ -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"]}'
```
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
@@ -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.
mutter-dev-bin package is required
```bash
dbus-run-session gnome-shell --devkit --wayland
```
before GNOME 48
```bash
dbus-run-session -- gnome-shell --nested [--wayland]
```
+26 -21
View File
@@ -104,7 +104,7 @@ class SignalMgt {
array.push(id);
id = widget.connect('scroll-event', this._onScroll.bind(this));
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);
}
@@ -150,7 +150,7 @@ class SignalMgt {
_doClickCallback() {
let right = '';
let nbClicks = '';
if (this.button == 3)
right = 'Right';
if (this.nbClicks > 1)
@@ -285,7 +285,7 @@ class MonitorWidget extends PanelMenu.Button {
Main.panel.addToStatusArea(this.fullname, this, position, box);
}
update(item) {
const prevWidget = this.widget;
const prevIcon = this.icon;
@@ -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 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');
const decoded_content = decoder.decode(contents);
let [result, contents] = GLib.file_get_contents(file.get_path());
const res = `<node>${decoded_content}</node>`;
return res;
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;
} else {
throw new Error(`Generic monitor: Could not load file: ${filename}`);
}
}
class GenericMonitorDBUS {
@@ -576,15 +588,9 @@ class GenericMonitorDBUS {
this.monitor_groups = {};
this.actor_clicked = {};
this.ClutterSettings = Clutter.Settings.get_default();
this._dbusImpl = null;
loadInterfaceXml(extension, 'dbus.xml')
.then( (xml) =>
{
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(xml, this);
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
this._dbusImpl.emit_signal('onActivate', null);
})
.catch((e) => { this.logger.error(e); });
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(loadInterfaceXml(extension, 'dbus.xml'), this);
this._dbusImpl.export(Gio.DBus.session, '/com/soutade/GenericMonitor');
this._dbusImpl.emit_signal('onActivate', null);
}
emitSignal(name, value) {
@@ -794,7 +800,6 @@ class GenericMonitorDBUS {
}
this.monitor_groups = {};
this._dbusImpl.unexport();
this._dbusImpl = null;
}
}
+2 -3
View File
@@ -2,10 +2,9 @@
"uuid": "generic-monitor@gnome-shell-extensions",
"name": "Generic Monitor",
"description": "Display text & icon on systray using DBUS",
"version": "21",
"version": "19",
"shell-version": [
"50",
"49"
"48",
],
"url": "https://forge.soutade.fr/soutade/GnomeShellGenericMonitor"
}