this post was submitted on 05 May 2024
9 points (100.0% liked)

KDE

5394 readers
102 users here now

KDE is an international technology team creating user-friendly free and open source software for desktop and portable computing. KDE’s software runs on GNU/Linux, BSD and other operating systems, including Windows.

Plasma 6 Bugs

If you encounter a bug, proceed to https://bugs.kde.org/, check whether it has been reported.

If it hasn't, report it yourself.

PLEASE THINK CAREFULLY BEFORE POSTING HERE.

Developers do not look for reports on social media, so they will not see it and all it does is clutter up the feed.

founded 1 year ago
MODERATORS
 

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?

top 3 comments
sorted by: hot top controversial new old
[–] Zamundaaa@discuss.tchncs.de 2 points 6 months ago

You can probably implement it in the script itself, but there's no external functionality to do it

[–] carmanaught@lemmy.world 2 points 6 months ago* (last edited 6 months ago) (1 children)

In theory, this may be possible by configuring scripts to run via kactivitymanagerd, when switching to/from an activity.

I've posted about kactivitymanagerd on 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 for activated and deactivated states 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 kreadconfig6 and kwriteconfig6 to read/write to kwinrc and then use something like qdbus to "reconfigure" KWin. Something like below as basic enable and disable scripts would be worth trying. Note: Check the ~/.config/kwinrc file for the correct key which I've assumed to be poloniumEnabled based on the id defined in the polonium.kwinscript archive.

For the activity to have it activate on when on the activity, this would be the activated script:

# Check if Polonium is disabled and enable it if it is. Also don't reconfigure KWin if it's already enabled.
enabled=`kreadconfig6 --file kwinrc --group Plugins --key poloniumEnabled`

if [ $enabled = "false" ]; then
  kwriteconfig6 --file kwinrc --group Plugins --key poloniumEnabled true

  # Reconfigure KWin after enabling Polonium
  qdbus org.kde.KWin /KWin reconfigure
fi

And the deactivated state script would be:

# Check if Polonium is enabled and disable it if it is. Also don't reconfigure KWin if it's already disabled.
enabled=`kreadconfig6 --file kwinrc --group Plugins --key poloniumEnabled`

if [ $enabled = "true" ]; then
  kwriteconfig6 --file kwinrc --group Plugins --key poloniumEnabled false

  # Reconfigure KWin after disabling Polonium
  qdbus org.kde.KWin /KWin reconfigure
fi

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 kactivitymanagerd stuff 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.

[–] TxzK@lemmy.zip 1 points 6 months ago

Thanks a lot! I'll try it out when I get time.