Avoiding multiple windows when flicking between programs

Hi all. Any ideas how to change my Plasma Desktop behavior. I want to select a Program Icon in the Panel and go to it regardless of which Desktop it is on. I keep accidentally opening many Dolphin Windows. I would prefer it take me to the current open Dolphin. It will be in Desktop 1. While working from Desktop 3, I would like to jump straight to it, without opening another.
I like to have say 4 Desktops with Firefox for example in Desktop 4 and Dolphin in Desktop 1. For some reason I keep going to the Panel for my next action and find myself opening duplicate window. It is habit I suppose, but it works for me - mostly.

A simple wrapper script should do this.

#!/usr/bin/bash
pgrep dolphin
if [ $? -ne 0 ]
then
     # It's not running, so launch it
     dolphin
else
     # It's running
     # Switch to the relevant desktop, raise the window and focus it
     wmctrl -a Dolphin
fi

Note that the wmctrl command searches for the window’s title, which is why I’ve put it in capitalised.
I haven’t tested this with multiple desktops as I only use one, but according to the manpage it should switch.

I wonder if this is what you are looking for? (See where my mouse pointer is):


Some of my programs already behave the way you want, but I have likely set those up individually at some point.

If you are okay with the Dolphin window showing on all desktops, then you could set up a window rule for it:

  1. Right-click on Dolphin’s titlebar, select “More Actions” => “Configure Special Application Settings”

  2. In the dialogue window that pops up, click on “+Add Property”. In the “Size & Position” section you will see an option for “Virtual Desktops”. Click on that to add it to the options window, then select “Apply Initially” to “All Desktops”:

Open Dolphin and it will now be displayed on all of your desktops.

Alternatively, if you don’t want to set up a window rule, if you right-click on Dolphin in the taskbar, the popup menu will show the option to “Move to Desktop”. You can then select “Move to All Desktops”.

↑ This! ↑

And, in Wayland, you can individually choose which desktops to display each program on! ← Using right-click on the titlebar; this seems unavailable via right-click on the program’s Panel tab.

You can add a “sticky” button to the window title bar, which, when clicked, makes the window visible on all desktops.

The button looks like a thumbnail in the default Breeze decoration. It used to already be on the title bar by default, but I guess the KDE developers felt that Windows users wouldn’t know what to do with it. :man_shrugging:

2 Likes

I forgot about that option. Thanks. I only use 1 desktop, so even though I do have the pin set to show on my titlebar, it doesn’t appear due to multiple virtual desktops not being active.

The “On all desktops” button can be dragged to the titlebar via:

System Settings => Appearance & Style => Colors & Themes => Window Decorations => Configure Titlebar Buttons (or just search for “titlebar” in System Settings).

2 Likes