How do i make activitiy switching keep the same virtual desktop?

back in plasma 5, this used to be the default behavior.
but now, it seems to keep a different virtual desktop selected per activity. for my use case this is very undesirable.

IE, if i am on virtual desktop 1 on activity A, if i switch to activity B i should remain on virtual desktop 1 rather than whatever i was last on in activity B

according the the help page, an option apparently exists. but i can find no such thing in the settings anywhere.

it would be greatly appreciated if someone could tell me where this setting actually resides!

The configuration setting to not remember virtual desktops was removed from the UI during the port of the configuration panel to QML. The comment says:

UI Changes:

  • Remove the VirtualDesktop switching setting, which was already
    getting dropped from KActivitiesManagerD.

The original “remember virtual desktop” function was created in 2012 without a configuration option - it was “the right thing”. The functionality was a bit later moved to a plugin and the configuration for that was simply enabling or disabling the plugin - the UI was just triggering that configuration.

As part of Plasma 6, and the change of the configuration panel to use the D-Bus API instead of directly updating configuration file (which was the reason the old setting required a restart - to re-read the configuration file), that configuration option was no longer exposed.

But the option is still in the configuration file, and you can go and change it yourself - this is one of those rare “we don’t think showing the configuration option makes sense, but we won’t remove the functionality” things that sometimes happen even in KDE.

To disable the “virtual desktop switching” Activity Manager plugin, open the file ~/.config/kactivitymanagerdrc in a text editor, locate the line that has

[Plugins]
org.kde.ActivityManager.VirtualDesktopSwitchEnabled=true

Change the word true to false, save, log out and log in again.

no such line exists in my config file (plugins category also did not exist in my config file). i will attempt adding the lines anyways… here goes!

unfortunately, no dice. that did not do anything.

I can confirm that this fix doesn’t work for me. My kactivitymanagerdrc file was empty, adding these lines and changing it to false had no effect. On Kubuntu 24.10, Plasma 6.1.5, Frameworks 6.6.0, Qt 6.6.2

I checked that updating kactivitymanagerdrc worked for me - quite a while ago, and from looking at the source code for Plasma 5, by 5.27 the code that consults that configuration no longer exists.

According to the comments in bug 482892 – Feature request: allow disabling "remember virtual desktop separately for each activity" you can just remove the plugin file (/usr/lib/x86_64-linux-gnu/qt6/plugins/kactivitymanagerd1/org.kde.ActivityManager.VirtualDesktopSwitch.so on Neon) and that would also prevent the the switching of virtual desktop on activity switch.

In Plasma 6.3, the virtual desktop tracking for activities has moved from the activity manager daemon into kwin (activities: remember the virtual desktop per activity (!5871) · Merge requests · Plasma / KWin · GitLab) and as part of that work, the VirtualDesktopSwitch plugin was removed completely (Remove per-activity desktop tracking (!33) · Merge requests · Plasma / Activity manager service · GitLab).

In the new setup there is no way to disable the feature, and the kwin MR also explains why disabling this feature no longer makes sense.

Will be interesting to see how this behaves.

The first commit’s message says “remember the virtual desktop per activity” the second commit’s message says “don’t remember virtual desktops when intentionally switching to a different one”.

I haven’t looked through all comments on the PR. Can you point me to the one that explains that?

The idea is that to solve bug #427579, when switching to the activity with the attention demanding window - you’d go directly to that application regardless of what kwin’s memory is about that activity. If you’d also look at the code - if the target window is in multiple desktops, it will go to the first regardless of what makes sense - I can already see the future bug report: “app is on VD 1 and 3 on activity A, I was on VD 3 in activity A, switched to activity B and now when app demands attention - activating it takes me to VD 1 instead of 3”. But that is for the future (also, I never use the “window on multiple, but not all, VDs” feature, so I don’t actually care).

Eric Edlund wrote in Remove setting for per-activity virtual desktop remembering (!1182) · Merge requests · Plasma / Plasma Desktop · GitLab :

I’m removing [the option to disable remembering] in preparation to make each activity have it’s own unique set of virtual desktops […]. When this happens, (and one VD is never in multiple activities), having this option won’t make any sense.

Ah, I see.
Bad news!

Maybe we can at least get an implementation that does not switch when the current window is also present in the other activity.

Hate it when the current plugin takes KMail away from me despite it being on all activities (and same desktop)

I’ve solved this using a shell script - it will read current desktop number, switch to the next activity, then switch to the saved desktop number.

#!/bin/sh
CURRENT="`qdbus6 org.kde.KWin /KWin currentDesktop`"
qdbus6 org.kde.ActivityManager /ActivityManager/Activities NextActivity
qdbus6 org.kde.KWin /KWin setCurrentDesktop $CURRENT

Save this to file switch-activity.sh then do chmod a+x switch-activity.sh

Open System Settings → Keyboard → Shortcuts, press Add New → Command or script, select your new script, and assign some global hotkey to it.

Alternatively you can use this command to switch to a particular activity instead of cycling to the next activity:

qdbus6 org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity 1833c4e9-5382-4e3c-a28b-dc3d26315a27

Replace 1833c4e9-5382-4e3c-a28b-dc3d26315a27 with your activity ID from ~/.config/kactivitymanagerdrc

I’ve just updated to Debian Trixie, so I will be using Plasma 6.3 for the next two years, and I can’t believe I still need to write shell scripts to use the desktop. But at least bug 455429 was fixed in this release, so that’s an improvement.

Ah, very good idea for a workaround :+1:

You could post this as a comment on 482892 – Feature request: allow disabling "remember virtual desktop separately for each activity"

I recently learned that there is a command line tool for activities which can, among other things, list the activities

plasma-activities-cli6 --list-activities

Instead of writing script that the user needs to remember to invoke - instead of using the standard activity switching keys/UI - how about monitoring for regular activity switches and “fixing the current VD” after Plasma used its internal mechanism to switch?

For reference - see my script here that does something else by monitoring the activity switcher, but you can get everything you need there.

This is also very cool! :+1: