-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
48 lines (39 loc) · 1.52 KB
/
Copy pathextension.js
File metadata and controls
48 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import St from 'gi://St';
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
export default class ColorPickerExtension extends Extension {
enable() {
this._indicator = new ColorPickerIndicator();
Main.panel.addToStatusArea("ypsilonpicker", this._indicator);
}
disable() {
if (this._indicator) {
this._indicator.destroy();
this._indicator = null;
}
}
}
const ColorPickerIndicator = GObject.registerClass(
class ColorPickerIndicator extends PanelMenu.Button {
_init() {
super._init(0.5, "ColorPickerIndicator");
let icon = new St.Icon({
gicon: Gio.icon_new_for_string(this._getExtensionPath() + "/icons/ypsilon-picker.svg"),
style_class: "system-status-icon",
});
this.add_child(icon);
this.connect("button-press-event", () => this._runColorPicker());
}
_getExtensionPath() {
return Extension.lookupByUUID("ypsilonpicker@gnome").path;
}
_runColorPicker() {
let scriptPath = this._getExtensionPath() + "/scripts/colorpicker.sh";
Util.spawn(["gnome-terminal", "--", "bash", "-c", scriptPath]);
}
}
);