Enable/Disable KWin Scripts depending on current activity?
So, I like working with tiled WMs sometimes though not always. And Polonium is working great for that in Plasma 6. But as I said, I don't want it enabled 24/7. And rather than open settings and toggling it on and off every time, it'd be wonderful if I could harness the power of KDE activities and automatically toggle it on in a particular activity and off on any other. Is it possible?
In theory, this may be possible by configuring scripts to run via
kactivitymanagerd, when switching to/from an activity.I've posted about
kactivitymanagerdon KDE Discuss where you can find some explanation, though you should also be able to find resources elsewhere that explain how to use it, but if you set up scripts foractivatedanddeactivatedstates for the relevant activity you want it enabled on, that will enable and disable the script via commands and I believe it should be able to work.As for the scripts, you should be able to utilize
kreadconfig6andkwriteconfig6to read/write tokwinrcand then use something likeqdbusto "reconfigure" KWin. Something like below as basic enable and disable scripts would be worth trying. Note: Check the~/.config/kwinrcfile for the correct key which I've assumed to bepoloniumEnabledbased on theiddefined in thepolonium.kwinscriptarchive.For the activity to have it activate on when on the activity, this would be the
activatedscript:And the
deactivatedstate script would be:I haven't tested these scripts and I'm not sure if anything odd might happen if you do the KWin "reconfigure" when changing activities, so you might need to test and play around with things. I can confirm that the
kactivitymanagerdstuff works in general though, as I've tested that generally and still have a VM configured with notification scripts as proof of concept that it works.Thanks a lot! I'll try it out when I get time.
You can probably implement it in the script itself, but there's no external functionality to do it