52

Is it possible to have the opened applications of the current workspace in the launcher but not the ones from other workspaces?

Glutanimate
  • 21,393
user165749
  • 521
  • 1
  • 5
  • 3
  • I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings... – Alvar Jun 09 '13 at 09:12
  • Hold down the SUPER key (Windows key) to display an overview of all available Unity shortcuts. Also check out this Q&A. – Glutanimate Jun 09 '13 at 17:44
  • I edited your second question concerning the shortcuts out of your post because it's a duplicate and has been answered before. I see that this is your first question (Welcome to Askubuntu!): It's easier for us to help you if you only ask one question per post. Please bear this in mind in the future when using AU. – Glutanimate Jun 09 '13 at 17:53
  • Same question as here. However, that one lacks an answer. – RPiAwesomeness Nov 07 '15 at 19:12
  • Probably not the answer your looking for but unity lack of customizability. If you have particular needs or want more control over your desktop, you should consider moving to a more flexible desktop environment, like KDE. – Conchylicultor Oct 19 '16 at 21:38
  • Try gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces true instead of installing dconf-editor. – sotmot Apr 06 '21 at 16:02

4 Answers4

71

For Ubuntu Dock shipped with Ubuntu 17.10 and later (with GNOME)

Well, Other answers are pretty old, so I think it is worth to add up-to-date answer. It is possible to do so right now and not too hard tbh (With Ubuntu 17.10 and it having Gnome).

Just use dconf-editor:

sudo apt install dconf-editor

Navigate to org > gnome > shell > extensions > dash-to-dock and check isolate-workspaces enter image description here

  • 2
    the question has absolutely nothing to do with the Dash To Dock Gnome Extension. the question is about Unity Launcher, which Dash To Dock isn't even compatible with Unity. – crookedleaf Feb 07 '18 at 23:26
  • 4
    @crookedleaf Ubuntu switched to GNOME with a rebaked dash-to-dock as default with 17.10. – Seth Aug 23 '18 at 15:53
  • 1
    @Seth But OP is using Unity, not Gnome. So either OP just used the "Unity" tag accidentally, or they are using an Ubuntu version with Unity. – crookedleaf Aug 23 '18 at 19:13
  • 5
    @crookedleaf Or we just need to keep questions updated so they have the latest answers too :) – Seth Aug 23 '18 at 19:24
  • 2
    Works great in 18.04 /w gnome. Thanks! Note the extension can also be easily installed from the website: https://extensions.gnome.org/extension/307/dash-to-dock/ – Jeff Ward Apr 16 '19 at 22:23
  • 1
    I don't know if this answered the question asked, but it certainly answered the question that I googled... – carbocation Dec 20 '19 at 13:00
  • Cool! With isolate workspace from dconf editor, now I can ungroup windows of same app! – Nam G VU Oct 04 '20 at 13:55
  • 5
    Works in Ubuntu 20.04 with GNOME – Nyxynyx Nov 05 '20 at 05:09
  • 4
    No need to install dconf editor. Just run gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces true. Works great with 20.04. – PerlDuck Feb 16 '21 at 15:25
  • Works in Ubuntu 21.04 with Gnome. Thank you! – Andrei B Jan 14 '22 at 21:18
7

How to make applications untraceable on (other) workspaces

Using xdotool's windowunmap, it is possible to hide a window completely. The window, nor its application, occurs any more in the launcher icon, and is not even listed any more in the output of wmctrl.

Theoretically, this could be connected to the "workspace-engine", that was used in this and this answer. That would have been the most elegant solution.

However, the process of only hiding windows on other workspaces and to automatically raise the ones on the current workspace is too demanding to use in an ongoing background script (for now), and not unlikely "to catch a cold" as well. Since windows are lost for good in case of errors, I therefore decided not to offer the procedure as an automatic (background-) process.

If this answer is nevertheless useful for you or not depends on the situation, and the reason why you'd like to hide icons of applications, running on other workspaces; the decision is yours.

The solution; what it is and how it works in practice

  • A script, available under a shortcut key, seemingly making all windows on the current workspace (and thus applications) disappear completely. That means the application's icon in the Unity launcher shows no activity of the application:

    Three running applications: enter image description here After pressing the shortcut key: enter image description here

  • Pressing the schortcut key combination again, the windows and their applications will re-appear.

  • Since the key combination will only hide the windows and applications from the current workspace, you can subsequently switch to another workspace without a sign of what is (hidden) on the current workspace.
  • Also unhiding is done (only) on the current workspace, so in short, the process of hiding and unhiding is doen completely independent per workspace.

The script

#!/usr/bin/env python3
import subprocess    
import os
import time

datadir = os.environ["HOME"]+"/.config/maptoggle"
if not os.path.exists(datadir):
    os.makedirs(datadir)
workspace_data = datadir+"/wspacedata_"

def get_wlist(res):
    res = get_res()
    try:
        wlist = [l.split() for l in subprocess.check_output(["wmctrl", "-lG"]).decode("utf-8").splitlines()]
        return [w for w in wlist if all([
            0 < int(w[2]) < res[0],
            0 < int(w[3]) < res[1],
            "_NET_WM_WINDOW_TYPE_NORMAL" in subprocess.check_output(["xprop", "-id", w[0]]).decode("utf-8"),
            ])]
    except subprocess.CalledProcessError:
        pass

def get_res():
    # get resolution
    xr = subprocess.check_output(["xrandr"]).decode("utf-8").split()
    pos = xr.index("current")
    return [int(xr[pos+1]), int(xr[pos+3].replace(",", "") )]

def current(res):
    # get the current viewport
    vp_data = subprocess.check_output(
        ["wmctrl", "-d"]
        ).decode("utf-8").split()
    dt = [int(n) for n in vp_data[3].split("x")]
    cols = int(dt[0]/res[0])
    curr_vpdata = [int(n) for n in vp_data[5].split(",")]
    curr_col = int(curr_vpdata[0]/res[0])+1
    curr_row = int(curr_vpdata[1]/res[1])
    return str(curr_col+curr_row*cols)

res = get_res()

try:
    f = workspace_data+current(res)
    wlist = eval(open(f).read().strip())
    for w in wlist:
        subprocess.Popen(["xdotool", "windowmap", w[0]])
    os.remove(f)
except FileNotFoundError:
    current_windows = get_wlist(res)
    open(f, "wt").write(str(current_windows))
    for w in current_windows:
        subprocess.Popen(["xdotool", "windowunmap", w[0]])

How to use

  1. The script needs both wmctrl and xdotool:

    sudo apt-get install wmctrl xdotool
    
  2. Copy the script into an empty file, save it as toggle_visibility.py
  3. Test- run the script: in a terminal window, run the command:

    python3 /path/to/toggle_visibility.py
    

    Now open a new terminal window (since the first one seemingly disappeared from the face of the earth) and run the same command again. All windows should re-appear.

    NB: make sure you do not have "valuable" windows open while testing

  4. If all works fine, add the command to a shortcut key combination: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

    python3 /path/to/toggle_visibility.py
    

Explanation

As said, the script uses xdotool's windowunmap, to (completely) hide windows and the applications they belong to. The script:

  • reads what is the current workspace
  • reads the windows, which exist on the current workspace (only)
  • writes the window list to a file, named after the current workspace
  • hides the windows

On the next run, the script:

  • checks if the file, corresponding to the current workspace exists
  • if so, reads the window list and un- hides the windows.

thus toggling visibility of windows and applications on the current workspace.

Jacob Vlijm
  • 83,767
  • Great. Now only if i can find a way to automatically execute the script when I move to the other workspace so they just magically disappear and then appear again when i move back. Maybe i could write a python script to replace the shortcut key for ctrl+shift+arrow key – thuyein Jan 26 '16 at 02:52
  • 1
    On 17.10 this is now possible. See other answers. – Martin Melka Feb 07 '18 at 19:54
5

Unfortunately it's impossible.

Unity always shows all applications from everywhere and there are no way to change this. There is a bug report - https://bugs.launchpad.net/ayatana-design/+bug/683170 But seems developers aren't going to do anything. Probably if you mark at the top of the page that this bug affects you it will help developers to understand importance of such option.

dofeoct
  • 167
  • 1
  • 3
  • 8
1

Hide app/window from alt-tab switcher

  1. install dconf-editor using following command
    • sudo apt-get install dconf-editor
  2. launch dconf-editor from menu or terminal using following command
    • dconf-editor
  3. in dconf visit the location
    • for app-swicther use following
      • /org/gnome/shell/app-switcher/current-workspace-only
    • for window-swithcer use following
      • /org/gnome/shell/window-switcher/current-workspace-only
    • note: you can also edit both
  4. turn off button/switch that says Use default value
  5. override the Custom value from false to true
  6. save changes by clicking on Apply button at bottom right of dconf