KWin Scripts
Last active
February 7, 2024 03:44
-
-
Save Zren/8335be3157a8230514d8f03427af7e66 to your computer and use it in GitHub Desktop.
KWin Scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onClientAdded(client) { | |
if (client.resourceName == "navigator" && client.resourceClass == "firefox") { | |
client.activeChanged.connect(function quickTileClientOnFocus(){ | |
workspace.slotWindowQuickTileLeft() | |
client.activeChanged.disconnect(quickTileClientOnFocus) | |
}) | |
} | |
} | |
workspace.clientAdded.connect(onClientAdded) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onClientAdded(client) { | |
client.clientStartUserMovedResized.connect(function startMove(){ | |
if (client.shadeable) { | |
client.shade = true | |
} | |
}) | |
client.clientFinishUserMovedResized.connect(function finishMove(){ | |
if (client.shadeable) { | |
client.shade = false | |
} | |
}) | |
} | |
// Bind events for new windows | |
workspace.clientAdded.connect(onClientAdded) | |
// Bind events for windows already open when script is activated | |
var clients = workspace.clientList() | |
for (var i = 0; i < clients.length; i++) { | |
var client = clients[i] | |
onClientAdded(client) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ignoredClientList = [ | |
'lutris', // "lutris", "Lutris" | |
'Steam', // "Steam", "Steam" | |
]; | |
function isIgnoredClient(client) { | |
var clients = workspace.clientList(); | |
for (var i = 0; i < ignoredClientList.length; i++) { | |
var ignoredClient = ignoredClientList[i]; | |
if (client.resourceClass == ignoredClient) { | |
return true; | |
} | |
} | |
return false; | |
} | |
function isBorderlessFullscreen(client) { | |
var screenArea = workspace.clientArea(KWin.ScreenArea, client); | |
// Note that we use >= here. | |
// CS:GO appears to not remove the window decorations... or something. | |
// The window was 1920x1109 on a 1920x1080 screen. | |
return client.width >= screenArea.width && client.height >= screenArea.height; | |
} | |
function onCurrentDesktopChanged(oldDesktop, movingClient) { | |
var numClientsOnDesktop = 0; | |
var fullScreenClient = null; | |
var clients = workspace.clientList(); | |
for (var i = 0; i < clients.length; i++) { | |
var client = clients[i]; | |
if (client.desktop == workspace.currentDesktop) { | |
if (!isIgnoredClient(client)) { | |
numClientsOnDesktop += 1; | |
} | |
if (client.fullScreen || isBorderlessFullscreen(client)) { | |
fullScreenClient = client; | |
} | |
} | |
} | |
if (numClientsOnDesktop == 1 && fullScreenClient && fullScreenClient.minimized) { | |
workspace.activeClient = fullScreenClient; // focus the window | |
// fullScreenClient.minimized = false; | |
} | |
} | |
workspace.currentDesktopChanged.connect(onCurrentDesktopChanged); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment