-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathextension.js
41 lines (33 loc) · 879 Bytes
/
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
const Meta = imports.gi.Meta;
function lastWSIndex() { return global.screen.n_workspaces - 1 }
function indexDown(activeWorkspaceIndex) {
if ( activeWorkspaceIndex < lastWSIndex() ) {
return activeWorkspaceIndex + 1;
}
return 0;
}
function indexUp(activeWorkspaceIndex) {
if (activeWorkspaceIndex > 0) {
return activeWorkspaceIndex - 1;
}
return lastWSIndex();
}
function get_neighbor(direction) {
var index = this.index();
if(direction === Meta.MotionDirection.UP || direction === Meta.MotionDirection.LEFT) {
index = indexUp(index);
} else {
index = indexDown(index);
}
return global.screen.get_workspace_by_index(index);
}
let old = {};
function init() {
old = Meta.Workspace.prototype.get_neighbor;
}
function enable() {
Meta.Workspace.prototype.get_neighbor = get_neighbor;
}
function disable() {
Meta.Workspace.prototype.get_neighbor = old;
}