Although gsettings
cannot change schemaless keys in dconf, dconf
can. You do not need to write your own program. What you can do to change the number of rows in the workspace switcher is:
- install the
dconf-tool
package
- run
dconf
as
dconf write /org/gnome/gnome-panel/layout/objects/workspace-switcher/instance-config/num-rows 2
You can play with lots of other gnome-panel entries with
dconf-editor
as well.
If we limit the setup to have a different set of launchers per desktop it is not very complicated. What we need is a script, running in the background to keep track of the current workspace and automatically alter the set of launchers accordingly.
1. A set of launchers per workspace
Let's say I have four workspaces, I want the following launchers to be available on the different workspaces:
workspace 1 > workspace 2 > workspace 3 > workspace 4 >
![enter image description here](https://i.stack.imgur.com/Y82fX.png)
- Workspace 1: Firefox / Idle
- Workspace 2: Gcolor2 / Gimp Image Editor / Inkskape
- Workspace 3: Abiword / Gnumeric / Mail Reader
- Workspace 4: Mines / Sudoku
How to set up
The script uses wmctrl
:
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 desktops, a folder named (exactly):
desktop_1
desktop_2
desktop_3
desktop_4
![<image5>](https://i.stack.imgur.com/YDmDv.png)
Create launchers for all applications (for all workspaces) on your desktop and copy them to the corresponding folders.
Copy the script below into an empty file, save it as change_launchers.py
. Test-run it by running in a terminal window the command:
python3 /path/to/change_launchers.py
If all works fine, add it to your startup applications
The script
#!/usr/bin/env python3
import subprocess
import os
import time
import shutil
home = os.environ["HOME"]
desktop_dir = home+"/"+"Desktop"
data_dirstr = home+"/desktop_data/desktop_"
get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")
def get_desktop():
return [l for l in get("wmctrl -d").splitlines() if "*" in l][0].split()[-1]
while True:
curr_dt1 = get_desktop()
time.sleep(1)
curr_dt2 = get_desktop()
# alter the set of launchers when workspace changes
if not curr_dt1 == curr_dt2:
datafolder = data_dirstr+curr_dt2
for f in [f for f in os.listdir(desktop_dir)if f.endswith(".desktop")]:
subject = desktop_dir+"/"+f
os.remove(subject)
for f in os.listdir(datafolder):
subject = datafolder+"/"+f; target = desktop_dir+"/"+f
shutil.copyfile(subject, target)
subprocess.call(["/bin/bash", "-c", "chmod +x "+target])
Note
In different localized versions of Ubuntu, the name of the "Desktop" folder may differ (In Dutch: "Bureaublad"). If in your Ubuntu version the name of the desktop folder is not "Desktop", change it in the line:
desktop_dir = home+"/"+"Desktop"
2. Extending possibilities, launchers and links
If we add a few lines to the script, the setting-per-workspace options can be extended with a altering set of links to directories:
On one workspace we have a e.g. a link to the Documents folder, combined with launchers of office applications:
![enter image description here](https://i.stack.imgur.com/XHsy0.png)
On another workspace we have a link to the Pictures folder, combined with launchers of Image editors:
![enter image description here](https://i.stack.imgur.com/Uss8C.png)
How to setup
The setup is pretty much the same as in option 1, but additionally, in the data folders (see option 1), create links to folders (using ln -s <source> <destination>
) you'd like to be available on the corresponding workspace:
![enter image description here](https://i.stack.imgur.com/JW94A.png)
The script
#!/usr/bin/env python3
import subprocess
import os
import time
import shutil
home = os.environ["HOME"]
desktop_dir = home+"/"+"Desktop"
data_dirstr = home+"/desktop_data/desktop_"
get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")
def get_desktop():
return [l for l in get("wmctrl -d").splitlines() if "*" in l][0].split()[-1]
while True:
curr_dt1 = get_desktop()
time.sleep(1)
curr_dt2 = get_desktop()
# alter the set of launchers & 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
if os.path.islink(subject) or subject.endswith(".desktop") :
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)
Best Answer
(UPDATE)... I just fixed a "bug" where the script (below) would only look for "panel_6"
... Also, the script will only be of use for a single-monitor system...
... However, looking into it a bit further, it may be possible with Dual/Multi-monitors.
... Here is a link to something about Panels on a second monitor...
... moving panels (between screens)
... Im not sure if it's what you're after, but is seems more appropriate for multi-monitors.
Assuming that there is no "built-in" way to do it, as seems to be the case, I've cobbled up a script to "sort-of" do it... It simply sets the panels of your choice to auto-hide... and you can choose which workspace(s) via the args.
You can bind the script to the same keys that Compiz currently uses to switch works-spaces...
If you use any other method to get to the next workspace, it won't work, but you can also use the script to toggle the panel(s) on/off... (ooops! I haven't got the time today to finish that bit... :(
I haven't fine-tuned it yet, but it works (up to a point). It may or may not suit you.
)
(You will need wmctrl
Here is the script as it currently stands: