Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/upgrade to new guidelines #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 55 additions & 6 deletions contents/ui/main.qml → contents/code/main.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QtQuick 2.0
import QtQuick 2.15
import org.kde.plasma.core 2.0 as PlasmaCore;
import org.kde.plasma.components 2.0 as Plasma;
import org.kde.kwin 2.0;
Expand All @@ -25,20 +25,48 @@ Item {
PlasmaCore.DataSource {
id: shell
engine: 'executable'

connectedSources: []

function run(cmd) {
shell.connectSource(cmd);
connectSource(cmd);
}

onNewData: {
shell.disconnectSource(sourceName);
var exitCode = data["exit code"]
var exitStatus = data["exit status"]
var stdout = data["stdout"]
var stderr = data["stderr"]
exited(sourceName, exitCode, exitStatus, stdout, stderr)
disconnectSource(sourceName)
}

onSourceConnected: {
connected(source)
}

signal connected(string source)
signal exited(string shell, int exitCode, int exitStatus, string stdout, string stderr)
}

Connections {
target: shell
function onExited(shell, exitCode, exitStatus, stdout, stderr) {
console.log('onExited', shell, exitCode, exitStatus, stdout, stderr)
console.log('exited out', stdout)
console.log('exited err', sterr)
}
function onConnected(source) {
console.log('connected', source)
}
}

/*
* create a new blur region for a window
* client : the window you want to target
*/
function onClientAdded(client) {
if (!shell) return;
console.log('FORCE-BLUR: targeting the following client:', JSON.stringify(client))

var cls = client.resourceClass.toString().toLowerCase();
var name = client.resourceName.toString().toLowerCase();
Expand All @@ -48,12 +76,23 @@ Item {
if (root.blurContent) {
registerHintUpdater(client);
} else {
var wid = "0x" + client.windowId.toString(16);
//var wid = "0x" + client.windowId.toString(16);
var wid = client.windowId;
console.log('FORCE-BLUR: targeting the following id:', wid)
console.log('FORCE-BLUR: executed: xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id ', wid)
shell.run("xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id " + wid);
}
}
}

/*
* debug function
*/
function debug(client) {
print("------ on debug ------", client)
print("------ on debug ------", client.windowId)
}

function registerHintUpdater(client) {
var prevWidth = client.geometry.width;
var prevHeight = client.geometry.height;
Expand All @@ -73,14 +112,21 @@ Item {
root.onClientGeometryChanged(client, 0, 0);
}

/*
* Update the blur area when the geometry of the window change
* client : the targeted window
* prevWidth : the width value before the change
* prevHeight : the height value before the change
*/
function onClientGeometryChanged(client, prevWidth, prevHeight) {
if (!shell) return;

/* Skip if window *size* isn't really changed */
if (client.geometry.width === prevWidth && client.geometry.height === prevHeight)
return;

var wid = "0x" + client.windowId.toString(16);
//var wid = "0x" + client.windowId.toString(16);
var wid = client.windowId;
var region = "0,0," + client.geometry.width + "," + client.geometry.height;
var cmd = "xprop -id " + wid + " -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION " + region
shell.run(cmd);
Expand All @@ -91,10 +137,13 @@ Item {
console.log(JSON.stringify(root.patterns));

var clients = workspace.clientList();
console.log("FORCE-BLUR: current list of clients:", JSON.stringify(clients));

for (var i = 0; i < clients.length; i++) {
root.onClientAdded(clients[i]);
}

workspace.onClientAdded.connect(root.onClientAdded);
workspace.onClientAdded.connect(root.debug);
}
}
18 changes: 0 additions & 18 deletions metadata.desktop

This file was deleted.

29 changes: 29 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"KPlugin": {

"Name": "Force Blur",
"Description": "Force-enable Blur effect for certain windows",
"Icon": "preferences-system-windows-script-test",

"Id": "forceblur",
"License": "MIT",
"Version": "0.7",

"Authors": [
{
"Email": "[email protected]",
"Name": "Eon S. Jeon"
}
],

"ServiceTypes": [
"KWin/Script"
]
},
"Keywords": "blur",

"X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted",
"X-Plasma-API": "declarativescript",
"X-Plasma-MainScript": "code/main.qml",
"KPackageStructure": "KWin/Script"
}