-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
54 lines (43 loc) · 1.25 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
//
// A gnome-shell extension that moves the panel to second display.
//
/*jshint esnext:true */
/*global imports, global */
const Main = imports.ui.main;
const panelBox = Main.layoutManager.panelBox;
let originalPanelX = panelBox.x,
originalPanelWidth = panelBox.width,
panelAllocationHandlerId,
secondaryMonitorID,
found = true;
function init() {
if (Main.layoutManager.primaryMonitor == Main.layoutManager.monitors[0]) {
secondaryMonitorID = 1;
} else {
secondaryMonitorID = 0;
}
if (Main.layoutManager.monitors[secondaryMonitorID] == undefined) {
found = false;
}
}
function enable() {
if (found) {
originalPanelX = panelBox.x;
originalPanelWidth = panelBox.width;
movePanel();
panelAllocationHandlerId = panelBox.connect('allocation-changed', movePanel);
}
}
function disable() {
panelBox.disconnect(panelAllocationHandlerId);
moveToIndex(Main.layoutManager.primaryIndex);
}
function movePanel() {
let index = (Main.layoutManager.primaryIndex + 1) % 2;
moveToIndex(index);
}
function moveToIndex(index) {
let monitor = Main.layoutManager.monitors[index];
panelBox.set_position(monitor.x, monitor.y);
panelBox.width = monitor.width;
}