2021-05-16 12:33:48 +00:00
|
|
|
/*
|
2024-06-04 16:55:13 +00:00
|
|
|
SPDX-FileCopyrightText: 2024 Arne Keller <arne.keller@posteo.de>
|
2021-05-16 12:33:48 +00:00
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
var windowName = null;
|
|
|
|
|
|
|
|
function isRelevant(client) {
|
|
|
|
// window caption should start with the specified string
|
|
|
|
return client.caption.indexOf(windowName) === 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleWindow() {
|
|
|
|
assertTrue(windowName != null, "ToggleWindow failed to load windowName from config!");
|
2024-06-04 16:55:13 +00:00
|
|
|
var allClients = workspace.windowList();
|
|
|
|
for (var i = 0; i < allClients.length; i++) {
|
2021-05-16 12:33:48 +00:00
|
|
|
if (isRelevant(allClients[i])) {
|
|
|
|
var prevMini = allClients[i].minimized;
|
|
|
|
allClients[i].minimized = !prevMini;
|
|
|
|
if (prevMini) {
|
2024-06-04 17:17:45 +00:00
|
|
|
workspace.activeWindow = allClients[i];
|
2021-05-16 12:33:48 +00:00
|
|
|
}
|
|
|
|
break; // only toggle one window
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
windowName = readConfig("WindowName", "Alacritty").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
options.configChanged.connect(init);
|
|
|
|
|
|
|
|
init();
|
|
|
|
registerShortcut("ToggleWindow", "Toggle Window", "Meta+F1", toggleWindow);
|