-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextension.js
127 lines (95 loc) · 3.38 KB
/
extension.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Dim Screen
*
* Based on the code from https://wiki.gnome.org/Projects/GnomeShell/Extensions/StepByStepTutorial#myFirstExtension
*
* by [email protected] (20161027)
*
*
*
*
* # README
# Install
TODO
# Development
### Build package
`gnome-extensions pack [email protected]`
### Run package in Wayland
`dbus-run-session -- gnome-shell --nested --wayland`
`gnome-extensions install [email protected] --force`
Open gnome-extensions in the new gnome window and enable the extension.
*/
const St = imports.gi.St; //Gobject-Introspection https://developer.gnome.org/gobject/stable/
const Main = imports.ui.main; //Main.layoutManager.monitor https://developer.gnome.org/gtk3/stable/
//const Tweener = imports.ui.tweener;
let text, button;
let currentOpacity = 10;
function _hideHello() {
Main.uiGroup.remove_actor(text);
text = null;
}
function _showHello() {
let monitor = Main.layoutManager.primaryMonitor;
//let monitor2 = Main.layoutManager.secondaryMonitor;
let myText = "Info: Monitor w:h=" + monitor.width + "/" + monitor.height + " ... x:y=" + monitor.x + "/" + monitor.y+ " | CurrentOpacity: " + currentOpacity;
//myText = "hi 2: " + monitor2.x;
if (!text) {
text = new St.Label({
style_class: 'helloworld-label',
text: myText
});
Main.uiGroup.add_actor(text);
} else {
_hideHello();
}
global.log("DIM: currentOpacity = " + currentOpacity);
text.opacity = currentOpacity;
// text.set_position(monitor.x + Math.floor(monitor.width / 2 - text.width / 2),
// monitor.y + Math.floor(monitor.height / 2 - text.height / 2));
text.set_position(0, 0); //override
text.set_width(monitor.width * 6); //simply give enough width
text.set_height(monitor.height * 6);
// Tweener.addTween(text,
// { opacity: 0,
// time: 20,
// transition: 'easeOutQuad',
// onComplete: _hideHello });
}
// change opacity when scrolled
function _changeOpacity() {
if(currentOpacity < 25) {
currentOpacity = currentOpacity - 1;
if(currentOpacity < 1) currentOpacity = 250;
} else {
currentOpacity = currentOpacity - 5;
}
_showHello();
}
// reset opacity when clicked
function _resetAndShowHello() {
currentOpacity = 100;
_showHello();
}
function init() {
global.log("test"); //https://smasue.github.io/gnome-shell-tw
button = new St.Bin({ style_class: 'panel-button',
reactive: true,
can_focus: true,
// x_fill: true,
// y_fill: false,
x_expand: true,
y_expand: false,
track_hover: true });
//usr/share/icons/gnome/scalable/actions/system-run-symbolic.svg
let icon = new St.Icon({ icon_name: 'dialog-information-symbolic',
style_class: 'panelItem' }); //system-status-icon
button.set_child(icon);
button.connect('button-press-event', _resetAndShowHello);
button.connect('scroll-event', _changeOpacity);
}
function enable() {
Main.panel._rightBox.insert_child_at_index(button, 0);
}
function disable() {
Main.panel._rightBox.remove_child(button);
}