Debuging kwin forceblur — SITREP 2

Bouteiller < A2N > Alan
4 min readSep 26, 2023

--

The SITREP series is a “blog like” article that I wrote to note and share some of my research, debugging or work. Take it like a vlog if you want.

I hope you find something interesting in it. Or, in the worst case scenario, I hope you have learned something reading it.

This is the following part of my previous attempt to debug KWIN Force Blur.

Okai for some reason I’ve never found a clue why the script doesn’t crash and at the same time doesn’t work.

So I decided to go for another journey on debugging this script and the first step was pretty simple : transforming the QML script into a JS script.

Why I'm doing that ? Because in the documentation the example say to do a JS script, so I supposed that the JS is the new format the dev want for the kwin script. But, hey, keep in mid that the documentation of KDE Plasma is pretty inconsistent in the best case and just non-existent in the worst case.

The second point is that the JS script is reloaded correctly when I disable and then enable the script whereas the QML script needs a reboot for some reason 🥸

So I managed to do something like that :

function getSettings() {
const brutTargets = 'kitty\nkeepassxc\nurxvt';
const targets = brutTargets.split('\n').map((target) => target.trim().toLowerCase());
return targets;
}

function blurWindow(client) {
var id = client.windowId; // client window id
var type = client.windowType.toString(); // client window type
var role = client.windowRole.toString().toLowerCase(); // client window role
var cls = client.resourceClass.toString().toLowerCase(); // client window class
var name = client.resourceName.toString().toLowerCase(); // client window name

const targets = getSettings();

if (targets.length > 0 && (targets.includes(name) || targets.includes(cls) || targets.includes(type) || targets.includes(role))) {
// blur the client
}
}

function init() {
print('PFB -- launch init');

// EXISTING CLIENTS
const clients = workspace.clientList();

print('PFB --', clients.length, 'found');

for (var i = 0; i < clients.length; i++) {
print('PFB -- old client', clients[i].windowId);
blurWindow(clients[i]);
}

// NEW CLIENTS
workspace.clientAdded.connect(function(client) {
print('PFB -- new client', client.windowId);
blurWindow(client);
});

}

init();

ATM I don't have set up the config window because the first thing I want to try is to blur a window. If the blur work, I’m going to do it next.

OK, now I reach the complex part : how to add the blur effect ?

I have some idea :

  • run the same command line
  • use the kwin api if they propose the method for that
  • praise raptor jesus to give me the answer

After trying to figure out how to execute a command line and post some question on diverse forum (reddit, kde discuss), where I never receive an answer, I decide to turn my focus on the KWIN API.

In this page I found all the methods, functions and properties for the API and nothing seem to give me the ability to add the blur or call for a command.

I also have listed all the “key” accessible via the “client” object like so :

Object.getOwnPropertyNames(client)

But I found nothing that can help me in the list…

This is just after losing myself into my web research that I found this post.

Hum dbus, yeah, why not after all.

Okai I never used this stuff, so I read pretty quickly the documentation posted here. And I check to the qdbus bash command help :

qdbus --help                 
Usage: qdbus [--system] [--bus busaddress] [--literal] [servicename] [path] [method] [args]

servicename the service to connect to (e.g., org.freedesktop.DBus)
path the path to the object (e.g., /)
method the method to call, with or without the interface
args arguments to pass to the call
With 0 arguments, qdbus will list the services available on the bus
With just the servicename, qdbus will list the object paths available on the service
With service name and object path, qdbus will list the methods, signals and properties available on the object

Options:
--system connect to the system bus
--bus busaddress connect to a custom bus
--literal print replies literally

Actually, this is the help command that help me the most in particular for this sentence :

With 0 arguments, qdbus will list the services available on the bus
With just the servicename, qdbus will list the object paths available on the service
With service name and object path, qdbus will list the methods, signals and properties available on the object

Ok that pretty cool, I don't have to search for days where is the list of the service !

After many tries and test to figure out what service I have to use, I found that :

org.kde.KDBusService.CommandLine                -- int(QStringList arguments, QString working-dir, QVariantMap platform-data)

And that the point where I am actually because when I run the command I have the following error and I don't find why wet :

qdbus org.kde.krunner /org/kde/krunner org.kde.KDBusService.CommandLine "ls" "~" "{}"
Sorry, can't pass arg of type 'QVariantMap'.

I’ll leave you there and go for a coffee. I’ll let you know as soon as I have a solution 😎

--

--

Bouteiller < A2N > Alan
Bouteiller < A2N > Alan

Written by Bouteiller < A2N > Alan

Ex dev - PM - tech and startup enthusiast 🚀

No responses yet