forked from soutade/GnomeShellGenericMonitor
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a046da30f2 | |||
| 3afd5ded5e | |||
| c6907ea93f | |||
| 53489ab67e | |||
| e291b79f2c | |||
| b4af852a0f |
@@ -13,8 +13,11 @@ OR
|
||||
|
||||
Create a symbolic link from your _.local_ directory and enable extension
|
||||
|
||||
ln -s $PWD/generic-monitor@gnome-shell-extensions/ ~/.local/share/gnome-shell/extensions/
|
||||
gnome-extensions enable generic-monitor@gnome-shell-extensions
|
||||
```bash
|
||||
ln -s $PWD/generic-monitor@gnome-shell-extensions/ ~/.local/share/gnome-shell/extensions/
|
||||
|
||||
gnome-extensions enable generic-monitor@gnome-shell-extensions
|
||||
```
|
||||
|
||||
Restart GNOME
|
||||
|
||||
@@ -24,6 +27,7 @@ DBUS protocol
|
||||
|
||||
All functions read JSON formatted parameters
|
||||
|
||||
```js
|
||||
notify():
|
||||
{
|
||||
"group": "groupname",
|
||||
@@ -64,26 +68,32 @@ All functions read JSON formatted parameters
|
||||
{
|
||||
"item": "<itemName>@<groupName>"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
DBUS object
|
||||
===========
|
||||
|
||||
<text_object> is defined as :
|
||||
<text_object> is defined as:
|
||||
```js
|
||||
"text" : {
|
||||
"name" : "" // Optional, used with popup nested element
|
||||
<signals_description>, // Optional, used with popup nested element
|
||||
"text" : "Text to be displayed",
|
||||
"style" : "CSS style to be applied", // Optional
|
||||
}
|
||||
```
|
||||
|
||||
<icon_object> is defined as :
|
||||
<icon_object> is defined as:
|
||||
```js
|
||||
"icon" : {
|
||||
"path" : "Icon path",
|
||||
"style" : "CSS style to be applied", // Optional
|
||||
}
|
||||
```
|
||||
|
||||
<picture_object> is defined as :
|
||||
<picture_object> is defined as:
|
||||
```js
|
||||
"picture" : {
|
||||
"name" : "" // Optional, used with popup nested element
|
||||
<signals_description>, // Optional, used with popup nested element
|
||||
@@ -91,18 +101,21 @@ DBUS object
|
||||
"width" : XXX, // Optional : Force width in pixels, can be -1 for defaut value
|
||||
"height" : XXX, // Optional : Force height in pixels, can be -1 for defaut value
|
||||
}
|
||||
```
|
||||
|
||||
<popup_object is defuned as :
|
||||
<popup_object> is defined as:
|
||||
```js
|
||||
"popup" : {
|
||||
"items": [<text_objects> and/or <picture_objects>]
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Signals description
|
||||
===================
|
||||
|
||||
Signals can be :
|
||||
|
||||
```js
|
||||
"on-click" : ["signal"|"delete"|"open-popup"|"close-popup"|"toggle-popup"]
|
||||
"on-dblclick" : ["signal"|"delete"|"open-popup"|"close-popup"|"toggle-popup"]
|
||||
"on-rightclick" : ["signal"|"delete"|"open-popup"|"close-popup"|"toggle-popup"]
|
||||
@@ -110,6 +123,7 @@ Signals can be :
|
||||
"on-enter" : ["signal"|"delete"|"open-popup"|"close-popup"|"toggle-popup"]
|
||||
"on-leave" : ["signal"|"delete"|"open-popup"|"close-popup"|"toggle-popup"]
|
||||
"on-scroll" : ["signal"|"delete"|"open-popup"|"close-popup"|"toggle-popup"]
|
||||
```
|
||||
|
||||
Targets :
|
||||
|
||||
@@ -118,9 +132,9 @@ Targets :
|
||||
* open-popup : Open the popup if there is one
|
||||
* close-popup : Close the popup if there is one
|
||||
* toggle-popup : Toggle (open/close) the popup if there is one
|
||||
|
||||
|
||||
Signal names emit when action "signal" is specified :
|
||||
|
||||
Signal names emit when action "signal" is specified:
|
||||
|
||||
* onClick
|
||||
* onDblClick
|
||||
@@ -131,11 +145,11 @@ Signal names emit when action "signal" is specified :
|
||||
* onScrollUp
|
||||
* onScrollDown
|
||||
|
||||
Each signal is sent with one parameter : "<itemName>@<groupName>"
|
||||
Each signal is sent with one parameter: "<itemName>@<groupName>"
|
||||
For popup nested elements, parameter is "<nestedName>@<itemName>@<groupName>"
|
||||
where nestedName can be empty if not defined by user
|
||||
|
||||
Other signals are available when extension is activated/deactivated :
|
||||
Other signals are available when extension is activated/deactivated:
|
||||
|
||||
* onActivate
|
||||
* onDeactivate
|
||||
@@ -144,13 +158,17 @@ Other signals are available when extension is activated/deactivated :
|
||||
Example
|
||||
-------
|
||||
|
||||
You can test it with command line :
|
||||
You can test it with command line:
|
||||
|
||||
gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMonitor --method com.soutade.GenericMonitor.notify '{"group":"new","items":[{"name":"first","on-click":"toggle-popup","text":{"text":"Hello","style":"color:green"},"popup":{"items":[{"picture":{"path":"/tmp/cat.jpg"}}]}}]}'
|
||||
```bash
|
||||
# Create new group and add items
|
||||
gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMonitor --method com.soutade.GenericMonitor.notify '{"group":"new","items":[{"name":"first","on-click":"toggle-popup","text":{"text":"Hello","style":"color:green"},"popup":{"items":[{"picture":{"path":"/tmp/cat.jpg"}}]}}]}'
|
||||
|
||||
gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMonitor --method com.soutade.GenericMonitor.deleteGroups '{"groups":["new"]}'
|
||||
# Delete group
|
||||
gdbus call --session --dest org.gnome.Shell --object-path /com/soutade/GenericMonitor --method com.soutade.GenericMonitor.deleteGroups '{"groups":["new"]}'
|
||||
```
|
||||
|
||||
Python examples are available @ https://indefero.soutade.fr/p/genericmonitor/source/tree/master/examples
|
||||
Python examples are available @ https://forge.soutade.fr/soutade/GnomeShellGenericMonitor/src/branch/master/examples
|
||||
|
||||
|
||||
Development
|
||||
@@ -158,12 +176,23 @@ Development
|
||||
|
||||
After doing code update, you can test it within a nested window. In other cases you have to restart GNOME.
|
||||
|
||||
dbus-run-session -- gnome-shell --nested [--wayland]
|
||||
mutter-dev-bin package is required
|
||||
|
||||
To see log & errors :
|
||||
```bash
|
||||
dbus-run-session gnome-shell --devkit --wayland
|
||||
```
|
||||
|
||||
journalctl /usr/bin/gnome-shell
|
||||
before GNOME 48
|
||||
|
||||
```bash
|
||||
dbus-run-session -- gnome-shell --nested [--wayland]
|
||||
```
|
||||
|
||||
To see log & errors:
|
||||
|
||||
```bash
|
||||
journalctl /usr/bin/gnome-shell
|
||||
```
|
||||
|
||||
Licence
|
||||
-------
|
||||
|
||||
+21
-26
@@ -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-release-event', this._clicked.bind(this));
|
||||
id = widget.connect('button-press-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,31 +555,19 @@ class MonitorWidget extends PanelMenu.Button {
|
||||
}
|
||||
});
|
||||
|
||||
// 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) {
|
||||
async 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);
|
||||
|
||||
let [result, contents] = GLib.file_get_contents(file.get_path());
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const decoded_content = decoder.decode(contents);
|
||||
|
||||
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}`);
|
||||
}
|
||||
const res = `<node>${decoded_content}</node>`;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
class GenericMonitorDBUS {
|
||||
@@ -588,9 +576,15 @@ class GenericMonitorDBUS {
|
||||
this.monitor_groups = {};
|
||||
this.actor_clicked = {};
|
||||
this.ClutterSettings = Clutter.Settings.get_default();
|
||||
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);
|
||||
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); });
|
||||
}
|
||||
|
||||
emitSignal(name, value) {
|
||||
@@ -800,6 +794,7 @@ class GenericMonitorDBUS {
|
||||
}
|
||||
this.monitor_groups = {};
|
||||
this._dbusImpl.unexport();
|
||||
this._dbusImpl = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -2,9 +2,10 @@
|
||||
"uuid": "generic-monitor@gnome-shell-extensions",
|
||||
"name": "Generic Monitor",
|
||||
"description": "Display text & icon on systray using DBUS",
|
||||
"version": "16",
|
||||
"version": "21",
|
||||
"shell-version": [
|
||||
"48"
|
||||
"50",
|
||||
"49"
|
||||
],
|
||||
"url": "https://forge.soutade.fr/soutade/GnomeShellGenericMonitor"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user