I have 4 workspaces configured on compiz . I would like to know if there is a way to have folders exclusively in the main desktop (1)? I would like to keep the others clear to see wallpapers.
Ubuntu 14.04 x64
I have 4 workspaces configured on compiz . I would like to know if there is a way to have folders exclusively in the main desktop (1)? I would like to keep the others clear to see wallpapers.
Ubuntu 14.04 x64
This answer is an edited version of this answer, but with the difference that this one is for Unity (instead of XFCE) and is to manage a set of (links to) folders per workspace, instead of application launchers. However, by uncommenting a line (see further below), you can also set a different set of application launchers per workspace at the same time.
The fact that it is for Unity makes the script slightly more complicated, but in principle, it works pretty much exactly the same.
An example:
workspace 1:
workspace 2 (3, 4):
In the solution below, not the actual folders appear on your desktop (or only on one of the workspaces, or any of your choice), but links to a (any) folder. From your comment I understand that is an acceptable solution to you.
This makes it effectively possible to have a (virtual) folder on one workspace, but not on another. A background script keeps track of the current workspace and changes the set of links on your desktop, according to how you set it up.
The script uses wmctrl
to get information on the current workspace:
sudo apt-get install wmctrl
In your home directory (not in a subdirectory, but on the "first" level), create a directory (exactly) named:
desktop_data
inside this directory, create for each of your (in this example four) desktops, a folder named (exactly):
desktop_1
desktop_2
desktop_3
desktop_4
In these folders, create links to all folders that you want to appear on the corresponding desktop. If, for example, you want the folder Documents
to appear on viewport (workspace) 1, create a link:
ln -s ~/Documents ~/desktop_data/desktop_1/Documents
and so on, for all folders you want to appear on the targeted desktop(s):
NB If you also want a set of launchers per desktop, add the launchers to the folder and make them executable (!).
Copy the script below into an empty file, save it as change_desktop.py
. Test-run it by running in a terminal window the command:
python3 /path/to/change_desktop.py
Switch workspaces like you use to do since the script acts on switching workspaces.
NB if you also want a set of launchers, specific to the different workspaces, uncomment the line:
if os.path.islink(subject) or subject.endswith(".desktop"):
but make sure the line:
# if os.path.islink(subject):
is commented out (put a #
in front of the line)
In the example above, the folders Documents
, Netwerkmap
and screen_notes
appear on workspace 1, but not on workspace 2 (3,4)
If all works fine, add it to your startup applications: Dash > Startup Applications > Add
#!/usr/bin/env python3
import subprocess
import os
import time
import shutil
home = os.environ["HOME"]
desktop_dir = home+"/"+"Bureaublad"
data_dirstr = home+"/desktop_data/desktop_"
get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")
# get resolution
xr = get("xrandr").split()
plus = 2 if xr[xr.index("connected")+1] == "primary" else 1
res = [int(n) for n in xr[xr.index("connected")+plus].split("+")[0].split("x")]
def get_dt():
# 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)
curr_dt1 = get_dt()
while True:
time.sleep(1)
curr_dt2 = get_dt()
# alter the set of links when workspace changes
if not curr_dt1 == curr_dt2:
datafolder = data_dirstr+curr_dt2
for f in os.listdir(desktop_dir):
subject = desktop_dir+"/"+f
# uncomment one of the two lines below
if os.path.islink(subject): # uncomment for only folders (links to) per workspace
# if os.path.islink(subject) or subject.endswith(".desktop") : # uncomment for folders and .desktop files per workspace
#
os.remove(subject)
for f in os.listdir(datafolder):
subject = datafolder+"/"+f; target = desktop_dir+"/"+f
if os.path.islink(subject):
os.symlink(os.readlink(subject), target)
else:
shutil.copy(subject,target)
curr_dt1 = curr_dt2
If the script starts up, it checks the screen's resolution. It then checks once per second what is the current workspace, and sees if there was a workspace switch. If so, it copies the links that you placed in the corresponding folder in ~/desktop_data
to your desktop, and removes the links that are not.
In your localized version of Ubuntu, Desktop
might be named differently ("Bureaublad" in Dutch for example). If so, change in the script the line:
desktop_dir = home+"/"+"Desktop"
to reflect your localized name of the Desktop
folder.
I'm sorry but this functionality is currently not supported. You could try play with 3rd-party software like screenlets but I would strongly not recommend it.