![]() Registered Member ![]()
|
In brief, how would I develop a QML script? How would I know that the script has no syntax errors? And where do I go to get the output for console.log()?
I'm looking to create a KDE version of this: https://extensions.gnome.org/extension/973/switcher/. Upon activating by hotkey, it shows a list of windows titles in the order of most recently used. The window can then be selected by just pressing a number key. I found the extension to be more useful than Alt - Tab. I want to return to using KDE, but this extension is too useful to switch back. I want to create something that can at least mimic the basics of the extension. I've searched around, and my takeaway is that the best approach is using KWin scripting. There doesn't seem to be a way to create GUI elements in Javascript. However, I saw that some QML extensions were able to create dialog boxes. I've attempted to mimic parts of the kwin-tiling extension (https://github.com/kwin-scripts/kwin-tiling/). I have the metadata.desktop pointing to my main.qml file. I then load it with
It appears in my list of KWin scripts, but the hotkey from KWin.registerShortcut() does not appear in the list of global hotkeys and pressing does nothing. I've tried finding a way to debug it, including using console.log(), but I can't find the output. I'm not deeply familiar with KDE's internals and searching online resulted in little success. How can I get debug and error output for a KWin QML script? Is there something similar to the Plasma Desktop Scripting Console, but for QML? Or can Javascript create GUI elements as well? Thanks in advance |
![]() Registered Member ![]()
|
I'm the author of Krohnkite(https://github.com/esjeon/krohnkite/), another tiling script, and it's also QML-based.
To see debugging outputs, you must restart your KWin from your terminal:
However, IIRC, some distros(Fedora and Ubuntu?) disable debugging output by default, and kdebugsettings tool is required to re-enable it. There will be a "custom rule" that disables all debugging output. Also, about showing a window, it seems like it's impossible to create window inside KWin script. I'm not 100% sure, but I've not been able to do that. Instead, you can start another process by abusing PlasmaCore.DataSource element. (See https://github.com/esjeon/kwin-forceblur/blob/master/contents/ui/main.qml#L21) |
![]() Registered Member ![]()
|
Just place your script under:
${HOME}/.local/share/kwin/scripts Following this structure: https://develop.kde.org/docs/extend/plasma/kwin/ And the examples at: /usr/share/kwin/scripts But don't use plasma-interactiveconsole, as it doesn't support QML. Instead use your regular text editor or IDE. And load the code into Kwin by creating and executing this other shell script:
For packaging your code, compress it with the format "zip" and the extension "kwinscript". Upload it to: https://store.kde.org |
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]