6

I am struggling with organizing my workspaces. I have one workspace per Project I am working on. Some applications I can fix to a single workspace, since they are only needed for a single project. Others (like Firefox) I need on all workspaces. Now, when I open Firefox from a workspace that does not have a Firefox instance in it, I am either taken to a workspace with a Firefox instance or a new Firefox instance is launched.

How can I always launch a new instance, when there is none in the current workspace? Turning on the "Launch new instance" plugin in gnome-tweaks launches new instances even if there is an instance open in the current workspace.

Basically, when I open Firefox (or any application that is not fixed to a workspace), I want the following to happen:
Is there an instance running in the current workspace? -> Give focus to that instance
Otherwise, launch a new instance in the current workspace.

How can I achieve that?

pomsky
  • 70,557
BenT
  • 63

3 Answers3

6

You need to "isolate" your current workspace. You can do that by using the Workspace Isolated Dash GNOME shell extension for example. However, since Ubuntu nowadays (version 17.10 and later) comes with Ubuntu Dock (a fork of Dash to Dock), you can activate this by simply running the following command in Terminal, no need to do anything extra:

gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces true
pomsky
  • 70,557
3

dconf-editor

in Ubuntu 20.04 LTS,
dconf-editor seems powerful (than gnome-tweaks)
and easy to use (than gsettings or dconf).

the workspace related options:

  • /org/gnome/shell/extensions/dash-to-dock/isolate-workspaces
  • /org/gnome/shell/app-switcher/current-workspace-only
  • /org/gnome/shell/window-switcher/current-workspace-only

Run dconf-editor, press Ctrl + L to input location path.


screenshot:

dconf-editor.png

yurenchen
  • 471
0

We need, Launch new instance and dash to panel extensions.

Then we need to set:

gsettings set org.gnome.shell.extensions.dash-to-panel isolate-workspaces true
gsettings set org.gnome.shell.app-switcher current-workspace-only true
gsettings set org.gnome.shell.window-switcher current-workspace-only true

This might not work for some applications unless you edit the .desktop for those apps as shown bellow.

Before that, please check: Launch New Instance: Not working on Ubuntu 18.04 Gnome on Xorg.

sublime has a "New Window" desktop action, but it's not recognized as that by gnome-shell because it doesn't use new-window as identifier.

So, for example:

[Desktop Entry]
Name=VSCodium
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/codium/codium --unity-launch %F
Icon=vscodium
Type=Application
StartupNotify=false
StartupWMClass=VSCodium
Categories=TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;application/x-codium-workspace;
Actions=new-empty-window;
Keywords=vscode;

[Desktop Action new-empty-window] Name=New Window Exec=/usr/share/codium/codium --new-window %F Icon=vscodium

Here, Look at the action identifier in Actions=new-empty-window; which is new-empty-window. It does not work. We have to copy the .desktop file in ~/.local/share/applications and then replace new-empty-window with new-window and then run update-desktop-database ~/.local/share/applications (then we may have to restart the gnome session using Alt+F2rEnter).

For some applications there might be no actions at all. For example, fsearch.

[Desktop Entry]
Version=1.0
Type=Application
Name=FSearch
Comment=A file search application focusing on performance and advanced features
Icon=io.github.cboxdoerfer.FSearch
TryExec=fsearch
Exec=fsearch
Categories=GTK;Utility;Core;
Keywords=search;fsearch;files;folders;music;video;documents;find;tool;everything;
StartupNotify=true

In this case we have to edit the file like bellow:

[Desktop Entry]
Version=1.0
Type=Application
Name=FSearch
Comment=A file search application focusing on performance and advanced features
Icon=io.github.cboxdoerfer.FSearch
TryExec=fsearch
Exec=fsearch
Categories=GTK;Utility;Core;
Keywords=search;fsearch;files;folders;music;video;documents;find;tool;everything;
StartupNotify=true
Actions=new-window;

[Desktop Action new-window] Name=New Window Exec=fsearch --new-window Icon=io.github.cboxdoerfer.FSearch

Please notice that I have added Actions=new-window; under [Desktop Entry] and then added [Desktop Action new-window]

Hope this helps.