Last active
December 15, 2015 05:48
-
-
Save baris/5211334 to your computer and use it in GitHub Desktop.
KWin script to automatically move and resize windows to fit left or right half of the screen when switching windows.
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 to_the_left = true; | |
previous_active_client_id = null; | |
function resize_client(client) { | |
geo = client.geometry; | |
geo.width = workspace.workspaceWidth / 2; | |
geo.height = workspace.workspaceHeight - 30; | |
client.geometry = geo; | |
} | |
function move_client(fun) { | |
for (var i = 0; i < 10; i++) { | |
fun(); | |
} | |
} | |
workspace.clientActivated.connect(function(client) { | |
if (client === null) { | |
return; | |
} else if (previous_active_client_id === null) { | |
previous_active_client_id = client.windowId; | |
} else if (previous_active_client_id === client.windowId) { | |
return; | |
} | |
resize_client(client); | |
if (to_the_left === true) { | |
move_client(workspace.slotWindowPackLeft); | |
to_the_left = false; | |
} else { | |
move_client(workspace.slotWindowPackRight); | |
to_the_left = true; | |
} | |
move_client(workspace.slotWindowPackUp); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment