Created
August 15, 2018 13:14
-
-
Save veggiesaurus/63c15831681dbf173419662dff25d1fc to your computer and use it in GitHub Desktop.
kwin_walie_script
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 screenWidth = 3840; | |
var screenHeight = 2160; | |
var taskbarHeight = 68; | |
var bezelX = 50; | |
var bezelY = 45; | |
function geomLeft() { | |
return { x: 0, y: 0, width: screenWidth, height: 2 * screenHeight - taskbarHeight + bezelY }; | |
} | |
function geomRight() { | |
return { x: screenWidth + bezelX, y: 0, width: screenWidth, height: 2 * screenHeight + bezelY }; | |
} | |
function geomTop() { | |
return { x: 0, y: 0, width: screenWidth * 2 + bezelX, height: screenHeight }; | |
} | |
function geomBottom() { | |
return { x: 0, y: screenHeight + bezelY, width: screenWidth * 2 + bezelX, height: screenHeight - taskbarHeight }; | |
} | |
function geomAll() { | |
return { x: 0, y: 0, width: screenWidth * 2 + bezelX, height: screenHeight * 2 - taskbarHeight + bezelY}; | |
} | |
function geomTopLeft() { | |
return { x: 0, y: 0, width: screenWidth, height: screenHeight }; | |
} | |
function geomTopRight() { | |
return { x: screenWidth + bezelX, y: 0, width: screenWidth, height: screenHeight }; | |
} | |
function geomBottomLeft() { | |
return { x: 0, y: screenHeight + bezelY, width: screenWidth, height: screenHeight - taskbarHeight }; | |
} | |
function geomBottomRight() { | |
return { x: screenWidth + bezelX, y: screenHeight + bezelY, width: screenWidth, height: screenHeight }; | |
} | |
function fillGeometry(geometry) { | |
workspace.activeClient.geometry = geometry; | |
} | |
function fillLeft(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x, y: geometry.y, width: geometry.width / 2, height: geometry.height}; | |
} | |
function fillRight(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x + geometry.width / 2, y: geometry.y, width: geometry.width / 2, height: geometry.height}; | |
} | |
function fillTop(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x, y: geometry.y, width: geometry.width, height: geometry.height / 2}; | |
} | |
function fillBottom(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x, y: geometry.y + geometry.height / 2, width: geometry.width, height: geometry.height / 2}; | |
} | |
function fillTopLeft(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x, y: geometry.y, width: geometry.width / 2, height: geometry.height / 2}; | |
} | |
function fillTopRight(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x + geometry.width / 2, y: geometry.y, width: geometry.width / 2, height: geometry.height / 2}; | |
} | |
function fillBottomLeft(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x, y: geometry.y + geometry.height / 2, width: geometry.width / 2, height: geometry.height / 2}; | |
} | |
function fillBottomRight(geometry) { | |
workspace.activeClient.geometry = {x: geometry.x + geometry.width / 2, y: geometry.y + geometry.height / 2, width: geometry.width / 2, height: geometry.height / 2}; | |
} | |
function getScreenGeometryFromWindow() { | |
var geometry = workspace.activeClient.geometry; | |
var midX = geometry.x + geometry.width / 2; | |
var midY = geometry.y + geometry.height / 2; | |
if (midX < screenWidth) { | |
if (midY < screenHeight) { | |
return geomTopLeft(); | |
} | |
else { | |
return geomBottomLeft(); | |
} | |
} | |
else { | |
if (midY < screenHeight) { | |
return geomTopRight(); | |
} | |
else { | |
return geomBottomRight(); | |
} | |
} | |
} | |
registerShortcut("WALIE: Fill Left", "WALIE: Fill Left", "Meta+Num+4", function() { | |
fillGeometry(geomLeft()); | |
}); | |
registerShortcut("WALIE: Fill Screen Left", "WALIE: Fill Screen Left", "Meta+Alt+Num+4", function() { | |
fillLeft(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill Right", "WALIE: Fill Right", "Meta+Num+6", function() { | |
fillGeometry(geomRight()); | |
}); | |
registerShortcut("WALIE: Fill Screen Right", "WALIE: Fill Screen Right", "Meta+Alt+Num+6", function() { | |
fillRight(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill Top", "WALIE: Fill Top", "Meta+Num+8", function() { | |
fillGeometry(geomTop()); | |
}); | |
registerShortcut("WALIE: Fill Screen Top", "WALIE: Fill Screen Top", "Meta+Alt+Num+8", function() { | |
fillTop(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill Bottom", "WALIE: Fill Bottom", "Meta+Num+2", function() { | |
fillGeometry(geomBottom()); | |
}); | |
registerShortcut("WALIE: Fill Screen Bottom", "WALIE: Fill Screen Bottom", "Meta+Alt+Num+2", function() { | |
fillBottom(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill All", "WALIE: Fill All", "Meta+Num+5", function() { | |
fillGeometry(geomAll()); | |
}); | |
registerShortcut("WALIE: Fill Top Left", "WALIE: Fill Top Left", "Meta+Num+7", function() { | |
fillGeometry(geomTopLeft()); | |
}); | |
registerShortcut("WALIE: Fill Screen Top Left", "WALIE: Fill Screen Top Left", "Meta+Alt+Num+7", function() { | |
fillTopLeft(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill Top Right", "WALIE: Fill Top Right", "Meta+Num+9", function() { | |
fillGeometry(geomTopRight()); | |
}); | |
registerShortcut("WALIE: Fill Screen Top Right", "WALIE: Fill Screen Top Right", "Meta+Alt+Num+9", function() { | |
fillTopRight(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill Bottom Left", "WALIE: Fill Bottom Left", "Meta+Num+1", function() { | |
fillGeometry(geomBottomLeft()); | |
}); | |
registerShortcut("WALIE: Fill Screen Bottom Left", "WALIE: Fill Screen Bottom Left", "Meta+Alt+Num+1", function() { | |
fillBottomLeft(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Fill Bottom Right", "WALIE: Fill Bottom Right", "Meta+Num+3", function() { | |
fillGeometry(geomBottomRight()); | |
}); | |
registerShortcut("WALIE: Fill Screen Bottom Right", "WALIE: Fill Screen Bottom Right", "Meta+Alt+Num+3", function() { | |
fillBottomRight(getScreenGeometryFromWindow()); | |
}); | |
registerShortcut("WALIE: Toggle FullScreen", "WALIE: Toggle FullScreen", "Meta+Num+0", function() { | |
workspace.activeClient.fullScreen = !workspace.activeClient.fullScreen; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment