Skip to content

Commit 183916b

Browse files
committed
release always-open-on-focused-screen v2.5
1 parent cf05720 commit 183916b

File tree

8 files changed

+72
-7
lines changed

8 files changed

+72
-7
lines changed

always-open-on-focused-screen/CHANGELOG.bbcode

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[h2]v2.5[/h2]
2+
[list]
3+
[*] fix metadata not found
4+
[/list]
5+
16
[h2]v2.4[/h2]
27
[list]
38
[*] make script automatically enabled after install

always-open-on-focused-screen/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v2.5
2+
- fix metadata not found
3+
14
## v2.4
25
- make script automatically enabled after install
36
- update package structure
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
- make script automatically enabled after install
2-
- update package structure
3-
- add install/uninstall scripts
4-
- add changelog in BB Code format
1+
- fix metadata not found
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
KWin Script Always Open on Focused Screen
3+
(C) 2021 Natalie Clarius <[email protected]>
4+
GNU General Public License v3.0
5+
*/
6+
7+
// when a client is activated
8+
focusedScreen = workspace.activeScreen;
9+
workspace.clientActivated.connect(function(client) {
10+
// update focused screen to screen client is on
11+
if (client == null || client.specialWindow) return;
12+
focusedScreen = client.screen;
13+
});
14+
15+
// when a client is added
16+
workspace.clientAdded.connect(function(client) {
17+
// move client to focused screen
18+
if (client == null || client.desktopWindow || client.dock) return;
19+
if (client.screen == focusedScreen) return;
20+
console.debug("sending client", client.caption, "to focused screen", focusedScreen);
21+
workspace.sendClientToScreen(client, focusedScreen);
22+
23+
// clip and move client into bounds of screen dimensions
24+
if (!(client.moveable && client.resizeable)) return;
25+
area = workspace.clientArea(KWin.MaximizeArea, client);
26+
// window width/height maximally screen width/height
27+
client.geometry.width = Math.min(client.width, area.width);
28+
client.geometry.height = Math.min(client.height, area.height);
29+
// left/top window edge between left and right/top and bottom screen edges
30+
client.geometry.x = Math.max(area.x, Math.min(area.x + area.width - client.width, client.x));
31+
client.geometry.y = Math.max(area.y, Math.min(area.y + area.height - client.height, client.y));
32+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
kpackagetool5 --type=KWin/Script --install package || kpackagetool5 --type=KWin/Script --upgrade package
2+
kpackagetool5 --type=KWin/Script --install . || kpackagetool5 --type=KWin/Script --upgrade .
33
qdbus org.kde.KWin /KWin reconfigure
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# KWin Script Always Open on Focused Screen
2+
# (C) 2021 Natalie Clarius <[email protected]>
3+
# GNU General Public License v3.0
4+
5+
[Desktop Entry]
6+
Name=Always Open on Focused Screen
7+
Name[de]=Immer auf fokussiertem Bildschirm öffnen
8+
Name[nl]=Altijd openen op gefocust scherm
9+
Comment=Always opens new windows on the monitor that has the focused window
10+
Comment[de]=Öffnet neue Fenster immer auf dem Bildschirm mit dem fokussierten Fenster
11+
Comment[nl]=Open nieuwe vensters altijd op het scherm met een gefocust venster
12+
Icon=preferences-system-windows
13+
14+
X-KDE-PluginInfo-Name=alwaysopenonfocusedscreen
15+
X-KDE-PluginInfo-Version=2.5
16+
X-KDE-PluginInfo-Author=Natalie Clarius
17+
X-KDE-PluginInfo-Email[email protected]
18+
X-KDE-PluginInfo-License=GPL v3.0
19+
X-KDE-PluginInfo-Website=https://store.kde.org/p/1618008/
20+
21+
Type=Service
22+
X-Plasma-API=javascript
23+
X-Plasma-MainScript=code/main.js
24+
X-KDE-ServiceTypes=KWin/Script,KCModule
25+
X-KDE-ConfigModule=kwin/effects/configs/kcm_kwin4_genericscripted
26+
X-KDE-PluginKeyword=alwaysopenonfocusedscreen
27+
X-KDE-ParentComponents=alwaysopenonfocusedscreen
28+
X-KDE-PluginInfo-EnabledByDefault=true

always-open-on-focused-screen/package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# get plugin info
44
name=$(basename "$PWD")
5-
version=$(grep -oP '(?<=X-KDE-PluginInfo-Version=).*' package/metadata.desktop)
5+
version=$(grep -oP '(?<=X-KDE-PluginInfo-Version=).*' ./metadata.desktop)
66
echo "$name v$version"
77

88
# generate changelog in markdown format
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
kpackagetool5 --type=KWin/Script --remove package
2+
kpackagetool5 --type=KWin/Script --remove .
33
qdbus org.kde.KWin /KWin reconfigure

0 commit comments

Comments
 (0)