-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrm_desk.js
30 lines (28 loc) · 884 Bytes
/
rm_desk.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
function closeEmptyDesktops() {
var windows = workspace.windowList();
var desktopWindowCount = {};
windows.forEach(function (window) {
window.desktops.forEach(function (desktop) {
desktopNumber = desktop.x11DesktopNumber;
if (desktopNumber in desktopWindowCount) {
desktopWindowCount[desktopNumber] += 1;
} else {
desktopWindowCount[desktopNumber] = 1;
}
})
});
for (var num = 1; num <= workspace.desktops.length; num++) {
if (!(num in desktopWindowCount)) {
var desktop = workspace.desktops[num - 1];
if (workspace.currentDesktop != desktop) {
workspace.removeDesktop(desktop);
}
}
}
}
registerShortcut(
"Close Empty Desktops",
"Close Empty Desktops",
"",
closeEmptyDesktops
);