Skip to content

Move active window to a specified position

License

GPL-3.0, GPL-2.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-2.0
COPYING
Notifications You must be signed in to change notification settings

GuannanHu/Active-Window-Position

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Move active window to a specified position

This is a Kwin script template to move the active window to a specified position with a keyboard shortcut. KDE's default tilting function moves windows inside its current monitor but not the main monitor if you have more than one. This script fixes the problem.

video1515934806

Installation

Download the released package then run in terminal

kpackagetool5 --type=KWin/Script -i yourfoldname/releasedPackage.zip

Or simply extract it to a single folder and copy the folder to

~/.local/share/kwin/scripts/

Usage

If you have a 4k in the middle horizontally and a 2k on each side vertically, Using the script as it is will move the active window as below:

"AWP Move Window to main Center", "Alt+Shift+S"
"AWP Move Window to main Bottom Left", "Alt+Shift+A"
"AWP Move Window to main Bottom Right", "Alt+Shift+D"
"AWP Move Window to Top Leftmost", "Alt+Shift+Q"
"AWP Move Window to Bottom Leftmost", "Alt+Shift+Z",
"AWP Move Window to Top Rightmost ", "Alt+Shift+E"
"AWP Move Window to Bottom Rightmost ", "Alt+Shift+C",
"AWP Move Window to main Top Left", ""
"AWP Move Window to main Top Right", "",

The above can be customized in main.js or in systemsettting:shortcut:kwin.

Customize your monitor setup

If you have different monitor positions. Specify the left top coordinates in main.js

var MMTop_Left_x = 1440;
var MMTop_Left_y = 0; // coordinates of the left top point of the main monitor.
var MM_width = 4096;
var MM_height = 2160; // dimensions of the main monitor.

var LMTop_Left_x = 0;
var LMTop_Left_y = 0; // coordinates of the left top point of the Leftmost monitor.
var LM_height = 2560;
var LM_width = 1440; // dimensions of the Leftmost monitor.

var RMTop_Left_x = 5536;
var RMTop_Left_y = 0; // coordinates of the left top point of the Rightmost  monitor.
var RM_height = 2560;
var RM_width = 1440; // dimensions of the Rightmost monitor.

Customize the positions

You can change the position where the window will move to by changing the value of (x,y) in the following. The top left of your whole x11 screen is (0,0). If you move one pixel down vertically, you have (0,1).

client.geometry = {
    x: MMTop_Left_x,
    y: MMTop_Left_y + MM_height - client.height,
}

Customize the size of the moved window.

Specify dimensions at client.width and client.width in main.js.

width: client.width,
height: client.height // the dimensions active window moves into

Uninstall

To remove this script's keybinding entries from systemsettings:shortcut, find the lines containing AWP in

~/.config/kglobalshortcutsrc

Delete those lines and save kglobalshortcutsrc. Next time you login they are gone in systemsettings. Do not kwin_x11 --replace, which will restart kwin and restore the shortcuts from systemsettings to kglobalshortcutsrc.

About

Move active window to a specified position

Resources

License

GPL-3.0, GPL-2.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-2.0
COPYING

Stars

Watchers

Forks

Packages

No packages published