Summary: | KWin JS scripting api missing workspace and other globals | ||
---|---|---|---|
Product: | [Plasma] kwin | Reporter: | Ólafur P <olafur.palsson2> |
Component: | scripting | Assignee: | KWin default assignee <kwin-bugs-null> |
Status: | REPORTED --- | ||
Severity: | normal | CC: | info |
Priority: | NOR | ||
Version: | 6.0.4 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Ólafur P
2024-04-18 08:41:42 UTC
I recently upgraded from Fedora 39 to 41. This upgraded my kde from version 5.something to 6.2.4. Since this upgrade my custom kwin scripts no longer work and it looks to be the same cause. My scripts depend on the function 'workspace.clientList()'. Since the upgrade I get errors on the console: kwin_scripting: /home/janssege/.local/share/plasma-interactiveconsole/interactiveconsoleautosave.js:1: error: Property 'clientList' of object KWin::QtScriptWorkspaceWrapper(0x5633d92a4090) is not a function I don't know if workspace has been replace with something else or whether this is a bug. I'd appreciate a workaround or a fix for this though. I have been studying this some more. I have found the scripting interface has a few incompatible changes between KDE 5 and 6. I didn't find a comprehensive explanation of this, but there is a start of such a document here: https://invent.kde.org/plasma/kwin/-/wikis/Porting-your-scripts-to-KWin-6 As to the results of your test script, I have found the existence of the 'workspace' variable depends on the context in which you run the script. If you run it in the "Plasma" context, indeed it doesn't exist. However if you run it in the "KWin" context, it does exist. The problem with the "KWin" context is that it won't print output directly. You can only get output from it in the journal. And even there, the "print" command won't output anything. If you replace "print" with "console.info" the output can be filtered in the journal using journalctl -f QT_CATEGORY=js QT_CATEGORY=kwin_scripting I don't know if there's an equivalent way to get this info on distributions that don't use the systemd journal. Now for my specific problem, I had to replace "workspace.clientList()" with "workspace.windowList()" and "workspace.activeClient" with "workspace.activeWindow". |