I’m trying to write a new KWin script. Because the documentation of the KWin API is severely outdated, writing a new script involves a lot of trial and error.
Until now, a “try” involved the following steps after saving my js file:
- In System Settings/Kwin Scripts: Disable the script (by clicking the tick box)
- In System Settings/Kwin Scripts: Click ‘Apply’
- In System Settings/Kwin Scripts: Remove the script (by clicking the trash bin)
- In System Settings/Kwin Scripts: Click ‘Apply’
- In a terminal, run
kpackagetool6 --type=KWin/Script -i /.../myscript/package/ - In System Settings/Kwin Scripts: switch to another view (e.g. ‘Virtual Desktops’)
- In System Settings: switch back to Kwin Scripts (making the newly reinstalled script visible)
- In System Settings/Kwin Scripts: Enable the newly reinstalled script (by clicking the tick box)
- In System Settings/Kwin Scripts: click ‘Apply’
That’s 9 steps, 8 involving the mouse, to try something new. Silly.
Building on AiwendilH’s answer in this Reddit thread and using kpackagetool6 -h, I found that the following 1-step solution works (change myscript to your script’s name, and /path/…/to to the location of your script):
#!/bin/sh
qdbus org.kde.KWin /Scripting unloadScript myscript && kpackagetool6 --type=KWin/Script -u /path/.../to/myscript/package && qdbus org.kde.KWin /KWin reconfigure
I started writing this post to ask for help. Now that I hope maybe it will help some people facing the same frustration as I was. Note that you don’t need to increment the version number of your script in metadata.jsonfor this to work.