mirror of
https://gitlab.com/arnekeller/kwin-toggle-window.git
synced 2024-11-08 17:40:36 +00:00
Initial commit
This commit is contained in:
commit
dfef4894e6
35
contents/code/main.js
Normal file
35
contents/code/main.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2021 Arne Keller <arne.keller@posteo.de>
|
||||
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!");
|
||||
var allClients = workspace.clientList();
|
||||
for (var i = 0; i < allClients.length; ++i) {
|
||||
if (isRelevant(allClients[i])) {
|
||||
var prevMini = allClients[i].minimized;
|
||||
allClients[i].minimized = !prevMini;
|
||||
if (prevMini) {
|
||||
workspace.activeClient = allClients[i];
|
||||
}
|
||||
break; // only toggle one window
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
windowName = readConfig("WindowName", "Alacritty").toString();
|
||||
}
|
||||
|
||||
options.configChanged.connect(init);
|
||||
|
||||
init();
|
||||
registerShortcut("ToggleWindow", "Toggle Window", "Meta+F1", toggleWindow);
|
17
metadata.desktop
Normal file
17
metadata.desktop
Normal file
@ -0,0 +1,17 @@
|
||||
[Desktop Entry]
|
||||
Name=Toggle Window
|
||||
Comment=Changes minimization state of one window
|
||||
Icon=preferences-system-windows-move
|
||||
Type=Service
|
||||
|
||||
X-KDE-ServiceTypes=KWin/Script
|
||||
X-Plasma-API=javascript
|
||||
X-Plasma-MainScript=code/main.js
|
||||
|
||||
X-KDE-PluginInfo-Author=Arne Keller
|
||||
X-KDE-PluginInfo-Email=arne.keller@posteo.de
|
||||
X-KDE-PluginInfo-Name=togglewindow
|
||||
X-KDE-PluginInfo-Version=0.1
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-KDE-PluginInfo-License=GPL-3.0
|
||||
X-KDE-PluginInfo-Category=Windows and Tasks
|
Loading…
Reference in New Issue
Block a user