Proper way to reload a KWin effect

I’m writing a KWin effect. When I make changes, what is the proper way to reload the script? (I don’t want to logout / log back in every time)

Here’s what I tried. (My effect is called osd_clock in folder osd-clock)

qdbus org.kde.KWin /Effects org.kde.kwin.Effects.unloadEffect osd_clock
kpackagetool6 --type KWin/Effect --upgrade osd-clock/

kbuildsycoca6 --noincremental

qdbus6 org.kde.KWin /KWin reconfigure

qdbus6 org.kde.KWin /Effects org.kde.kwin.Effects.loadEffect osd_clock

However the new version of the effect doesn’t seem to get loaded until I logout and log back in. Is there a better way?

Thanks in advance

PS: I"m using Wayland on arch if that matters.

Operating System: Arch Linux
KDE Plasma Version: 6.6.4
KDE Frameworks Version: 6.26.0
Qt Version: 6.11.0
Kernel Version: 6.18.28-1-lts (64-bit)
Graphics Platform: Wayland

total stab in the dark but have you tried just restarting the plasmashell

systemctl restart --user plasma-plasmashell.service

when things seem out of sync, i try these things in order:

  • refresh application view (if offered)

  • restart plasmashell

  • log out

  • reboot

  • restore from backup

I had similar problems when working on KWin scripts. I therefore hacked together a small helper script: https://github.com/Flupp/sticky-window-snapping/blob/master/tools.bash. Maybe it can be adapted to your case. Have a look at the reinstall sub-command (function cmd_x_reinstall()).

Thanks; So I don’t want to do a whole restart as that will be a pain when developing an effect.

I looked at your script @Flupp . Thanks. It’s similar to what I was doing, but had some extra sleeps and a kwriteconfigfile commands, which I copied, and tried this:

qdbus org.kde.KWin /Effects org.kde.kwin.Effects.unloadEffect osd_clock
kwriteconfig6 --file kwinrc --group Plugins --key "osd_clockEnabled" false
qdbus org.kde.KWin /KWin reconfigure
sleep 1

kpackagetool6 --type KWin/Effect --upgrade osd-clock/
#rm -f ~/.cache/kwin/qmlcache/*.qmlc
kbuildsycoca6 --noincremental
qdbus org.kde.KWin /KWin reconfigure
sleep 1


set +e
kwriteconfig6 --file kwinrc --group Plugins --key "osd_clockEnabled" true
qdbus org.kde.KWin /KWin reconfigure
sleep 1

qdbus org.kde.KWin /Effects org.kde.kwin.Effects.loadEffect osd_clock

I had no luck. I couldn’t reload the effect.

I ended up just starting a second plasma session (or more correctly a windowed kwin_wayland process) and used that for testing.

Thanks for your help.