KDE Snap Assistant / Tiling Assisant Feature

There was a nice feature called KDE Snap Assistant that broke because Plasma 6 introduced fundamental architectural changes without caring to create a compatibility layer that shattered the scripting ecosystem. The dev simply gave up on KDE after that, as you can see here: Add support for Plasma 6 · Issue #47 · emvaized/kde-snap-assist · GitHub

The Problem is that KWin’s QML modules were inconsistently ported: some components moved to v3.0, others stayed at 2.0, and some were completely removed. The workspace object is no longer automatically injected into all QML/JS contexts. It’s only available in specific execution environments.

Considering hell, I decided to port KDE Snap Assistant to Plasma 6 so I can have the only Micro$oft Windows feature (Windows Snap Assistant) that keeps me on the hook that is easing my workflow managing windows with visual aids created once you snap a windows on the side of your screen, WITHOUT THE NEED OF KEYBOARD USAGE. There is no feature like that on KDE Plasma 6 yet, period. There’s on Gnome though (Tiling Assistant) AND on Samsung Dex (Android) though.

Going through this painfully, I’m rn facing a classic bootstrapping problem where each solution requires the other to work first:

Problem A: JavaScript Can’t Access QML

// main.js - CAN detect snaps, but...
function showInterface() {
    // ❌ Qt.createComponent() - NOT AVAILABLE in KWin scripting context
    // ❌ Can't instantiate QML from JavaScript
    // ❌ Can't show visual interface with thumbnails
}

Problem B: QML Can’t Access KWin APIs

// main.qml - CAN show interface, but...
Item {
    Component.onCompleted: {
        // ❌ workspace is not defined
        // ❌ Can't detect window events
        // ❌ Can't access window objects
    }
}

Problem C: Communication Channel Broken

// The Bridge is BROKEN
workspace.someProperty = data  // ❌ Not be accessible from QML AFAIK
globalThis.sharedData = data   // ❌ globalThis doesn't exist in KWin

The Vicious Cycle:

  • JavaScript has KWin API access but can’t create UI
  • QML can create UI but can’t access KWin APIs
  • Communication between them is unreliable or non-existent

I tried my best to get creative and thought to custom TabBox component but I started to notice that I had to beginning to change Kwin itself to make it work once * TabBox infrastructure exists but can’t be programmatically triggered. TabBox infrastructure exists but and can’t be programmatically triggered afaik, being defined only to answer to keyboard shortcuts. Besides that when TabBox activates, it hijacks the entire input system. This makes it impossible to trigger from within a script’s event handler.

I don’t know how the heck did they manage to fragments these capabilities across incompatible contexts. It’s truly a technological marvel.

Am I missing something? How can I solve that? Are they planning on launching a unified scripting API, programmatic UI activation or cross-context communication or if this is a must for me I should just give up on KDE to get onboard of Wayland? I can’t see a solution that doesnt involvers having to change Kwin itself to make it work. HELP :folded_hands::folded_hands::folded_hands::folded_hands::folded_hands:

Or can I ask a Snap Assistant for KDE as a native feature for Christmas?

Okay I bite the bullet and this is where I am at

JS scripting can’t create UI but Workspace and several other things can in fact be accessed from QML KWin scripts, from JS files imported to QML even

Pushed my progress here: GitHub - luisbocanegra/kde-snap-assist at plasma6 will try to finish the port and fix the bugs I find in the next few days

3 Likes

You’re amazing @luisbocanegra . So it was skill issue after all.

I was about to mark as solved but I tested your code and I couldn’t replicate the behavior. The kwin script did not initialized. I’ll figure out why and report.

More like outdated documentation sadly, but one can get away by reading existing add-ons and even KWin source code even. For a C++ noob like me, though most of the time I just dump all properties and functions of an object (like ‘Workspace’) to the log and search these properties and methods in KDE/Qt source code if I need to know more about something.

Works most of the time but it would be great to have updated documentation, but I understand because KWin is a beast and I am sure there are way too many things to work on, specially with the Wayland stuff

Yeah I only focused on getting it to launch but you’re probably hitting a bug, I’ll enable issues in the fork if you want to report it there or help fixing stuff

ezgif-42ff775f3eb40f

Managed to make it work. For some reason, console windows were not detecting snap on my laptop but it is working fine on the the desktop. No console logs were issued on that, so I have no idea what is happening. I’ll report on the repo on that when I find out why.

In any case, nicely done! It was incredible.