How to properly reload a kwin script

Hello, I want to debug a kwin script but when I add some code in it and reinstall it nothing have changed.

I follow this instruction :

  • made my update in the code (like a console.log for example)
  • uninstall the script via the system settings page
  • run kpackagetool5 --type=KWin/Script -i ~/Downloads/forceblur
  • run qdbus org.kde.KWin /KWin reconfigure
  • activate the script via the system settings page

What I miss ?

My test is pretty simple, I just add a console.log and check if it’s added to my journalctl -f, the only moment it has worked it’s when I rename the kwin script :confused:

1 Like

I had trouble with it too.

What I found so far is to do 2 DBUS calls:

  1. call org.kde.kwin.Scripting.unloadScript name_of_your_script

  2. Update/reinstall the extensions

  3. call org.kde.kwin.Scripting.start

KWin reconfigure had no effect for me, but “start” reloaded the new new extension nicely.

You can see an example here: https://github.com/ragusa87/kde-tilling-on-drag/blob/main/Makefile

2 Likes

It seems, reconfigure only has an effect when some configuration changed. I reload a KWin script by disabling the script, reconfiguring, sleeping, enabling the script, and reconfiguring. I wrote a small helper script tools.bash for that. During development, I usually call ./tools.bash remove install reconfigure after a change I’d like to test. There might be more elegant ways but so far it works good enough for me.

I see you are using org.kde.kwin.Scripting.unloadScript and org.kde.kwin.Scripting.start which are not present at KWin scripting API | Developer. Are they documented somewhere?
Btw, I asked basically the same question at How to apply KDE Plasma KWin script change without restarting KWin?