Setting to only show applications of current workspace in launcher?












23















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










share|improve this question

























  • I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings...

    – Alvar
    Jun 9 '13 at 9: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 9 '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 9 '13 at 17:53













  • Same question as here. However, that one lacks an answer.

    – RPiAwesomeness
    Nov 7 '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
















23















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










share|improve this question

























  • I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings...

    – Alvar
    Jun 9 '13 at 9: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 9 '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 9 '13 at 17:53













  • Same question as here. However, that one lacks an answer.

    – RPiAwesomeness
    Nov 7 '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














23












23








23


11






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










share|improve this question
















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







unity launcher workspaces






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 9 '13 at 17:50









Glutanimate

16.1k873131




16.1k873131










asked Jun 9 '13 at 9:02









user165749user165749

11613




11613













  • I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings...

    – Alvar
    Jun 9 '13 at 9: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 9 '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 9 '13 at 17:53













  • Same question as here. However, that one lacks an answer.

    – RPiAwesomeness
    Nov 7 '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



















  • I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings...

    – Alvar
    Jun 9 '13 at 9: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 9 '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 9 '13 at 17:53













  • Same question as here. However, that one lacks an answer.

    – RPiAwesomeness
    Nov 7 '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

















I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings...

– Alvar
Jun 9 '13 at 9:12





I think ctrl + (1,2,3,4) is used for switching workspaces. But check shortcuts in the system settings...

– Alvar
Jun 9 '13 at 9: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 9 '13 at 17:44







Hold down the SUPER key (Windows key) to display an overview of all available Unity shortcuts. Also check out this Q&A.

– Glutanimate
Jun 9 '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 9 '13 at 17:53







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 9 '13 at 17:53















Same question as here. However, that one lacks an answer.

– RPiAwesomeness
Nov 7 '15 at 19:12





Same question as here. However, that one lacks an answer.

– RPiAwesomeness
Nov 7 '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





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










3 Answers
3






active

oldest

votes


















11














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






share|improve this answer





















  • 1





    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 7 '18 at 23:26






  • 1





    @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






  • 1





    @crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

    – Seth
    Aug 23 '18 at 19:24



















8














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.






share|improve this answer


























  • 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

    – Thu Yein Tun
    Jan 26 '16 at 2:52








  • 1





    On 17.10 this is now possible. See other answers.

    – Martin Melka
    Feb 7 '18 at 19:54



















6














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.






share|improve this answer





















  • 1





    Don't comment on the bug report, just mark it as affecting you at the top of the page.

    – Flimm
    Sep 18 '13 at 14:22











  • @Flimm do you happen to know what desktop manager has this funcionality?

    – Cesar
    Sep 13 '14 at 3:25






  • 2





    unity looks great but the lack of customizability is really frustrating.

    – Programster
    Aug 26 '15 at 9:22











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f305962%2fsetting-to-only-show-applications-of-current-workspace-in-launcher%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









11














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






share|improve this answer





















  • 1





    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 7 '18 at 23:26






  • 1





    @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






  • 1





    @crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

    – Seth
    Aug 23 '18 at 19:24
















11














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






share|improve this answer





















  • 1





    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 7 '18 at 23:26






  • 1





    @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






  • 1





    @crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

    – Seth
    Aug 23 '18 at 19:24














11












11








11







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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 26 '18 at 15:05









pomsky

29.3k1190116




29.3k1190116










answered Feb 1 '18 at 12:39









Jakub KopyśJakub Kopyś

2781311




2781311








  • 1





    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 7 '18 at 23:26






  • 1





    @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






  • 1





    @crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

    – Seth
    Aug 23 '18 at 19:24














  • 1





    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 7 '18 at 23:26






  • 1





    @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






  • 1





    @crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

    – Seth
    Aug 23 '18 at 19:24








1




1





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 7 '18 at 23:26





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 7 '18 at 23:26




1




1





@crookedleaf Ubuntu switched to GNOME with a rebaked dash-to-dock as default with 17.10.

– Seth
Aug 23 '18 at 15:53





@crookedleaf Ubuntu switched to GNOME with a rebaked dash-to-dock as default with 17.10.

– Seth
Aug 23 '18 at 15:53




1




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





@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




1




1





@crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

– Seth
Aug 23 '18 at 19:24





@crookedleaf Or we just need to keep questions updated so they have the latest answers too :)

– Seth
Aug 23 '18 at 19:24













8














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.






share|improve this answer


























  • 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

    – Thu Yein Tun
    Jan 26 '16 at 2:52








  • 1





    On 17.10 this is now possible. See other answers.

    – Martin Melka
    Feb 7 '18 at 19:54
















8














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.






share|improve this answer


























  • 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

    – Thu Yein Tun
    Jan 26 '16 at 2:52








  • 1





    On 17.10 this is now possible. See other answers.

    – Martin Melka
    Feb 7 '18 at 19:54














8












8








8







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 13 '17 at 12:24









Community

1




1










answered Nov 8 '15 at 21:42









Jacob VlijmJacob Vlijm

63.7k9125219




63.7k9125219













  • 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

    – Thu Yein Tun
    Jan 26 '16 at 2:52








  • 1





    On 17.10 this is now possible. See other answers.

    – Martin Melka
    Feb 7 '18 at 19:54



















  • 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

    – Thu Yein Tun
    Jan 26 '16 at 2:52








  • 1





    On 17.10 this is now possible. See other answers.

    – Martin Melka
    Feb 7 '18 at 19:54

















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

– Thu Yein Tun
Jan 26 '16 at 2:52







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

– Thu Yein Tun
Jan 26 '16 at 2:52






1




1





On 17.10 this is now possible. See other answers.

– Martin Melka
Feb 7 '18 at 19:54





On 17.10 this is now possible. See other answers.

– Martin Melka
Feb 7 '18 at 19:54











6














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.






share|improve this answer





















  • 1





    Don't comment on the bug report, just mark it as affecting you at the top of the page.

    – Flimm
    Sep 18 '13 at 14:22











  • @Flimm do you happen to know what desktop manager has this funcionality?

    – Cesar
    Sep 13 '14 at 3:25






  • 2





    unity looks great but the lack of customizability is really frustrating.

    – Programster
    Aug 26 '15 at 9:22
















6














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.






share|improve this answer





















  • 1





    Don't comment on the bug report, just mark it as affecting you at the top of the page.

    – Flimm
    Sep 18 '13 at 14:22











  • @Flimm do you happen to know what desktop manager has this funcionality?

    – Cesar
    Sep 13 '14 at 3:25






  • 2





    unity looks great but the lack of customizability is really frustrating.

    – Programster
    Aug 26 '15 at 9:22














6












6








6







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 18 '13 at 17:54

























answered Sep 1 '13 at 21:29









dofeoctdofeoct

109138




109138








  • 1





    Don't comment on the bug report, just mark it as affecting you at the top of the page.

    – Flimm
    Sep 18 '13 at 14:22











  • @Flimm do you happen to know what desktop manager has this funcionality?

    – Cesar
    Sep 13 '14 at 3:25






  • 2





    unity looks great but the lack of customizability is really frustrating.

    – Programster
    Aug 26 '15 at 9:22














  • 1





    Don't comment on the bug report, just mark it as affecting you at the top of the page.

    – Flimm
    Sep 18 '13 at 14:22











  • @Flimm do you happen to know what desktop manager has this funcionality?

    – Cesar
    Sep 13 '14 at 3:25






  • 2





    unity looks great but the lack of customizability is really frustrating.

    – Programster
    Aug 26 '15 at 9:22








1




1





Don't comment on the bug report, just mark it as affecting you at the top of the page.

– Flimm
Sep 18 '13 at 14:22





Don't comment on the bug report, just mark it as affecting you at the top of the page.

– Flimm
Sep 18 '13 at 14:22













@Flimm do you happen to know what desktop manager has this funcionality?

– Cesar
Sep 13 '14 at 3:25





@Flimm do you happen to know what desktop manager has this funcionality?

– Cesar
Sep 13 '14 at 3:25




2




2





unity looks great but the lack of customizability is really frustrating.

– Programster
Aug 26 '15 at 9:22





unity looks great but the lack of customizability is really frustrating.

– Programster
Aug 26 '15 at 9:22


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f305962%2fsetting-to-only-show-applications-of-current-workspace-in-launcher%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mont Emei

Province de Neuquén

Journaliste