I'd been searching for some time for someone to come up with a solution for showing icons and backgrounds unique to a Workspace. I finally came up with my own. This is my first posting, so I will introduce myself simply as a retired software developer and QA who has only recently re-acquainted myself with Linux.
Currently running on Linux Mint 20, Cinnamon 4.6.7 Kernel: Linux 5.4.0-89-generic, Architecture: x86-64
This implementation allows each Workspace to have its own background and set of Desktop icons. So, if I was working (Ha Ha, I'm retired), I could switch to my work related desk and have just work related icons available. Then, when it's time to play, I could switch to my games related desk.
Changes from one Desktop to another are quick, as the script is merely symbolically linking Desktop to target Desk folders and invoking gsettings. No need to copy items from one folder to another.
To change Backgrounds for a Desk, simply use the default Background switcher. The script below automatically saves the new background in a link file on the Desk upon switching to another Desktop. No need to edit a script or config file.
Step 1 - Change Desktop to a symbolic link. Preserve original Desktop folder contents in Desk1.
Note: Desktop appears to be "magical' in that it will reappear if moved/removed. So move and link in one line.
cd ~
mv Desktop Desk1; ln -sfn Desk1 Desktop
Step 2 - Create folders for other Desks.
Be careful not to re-create Desk1!
mkdir Desk2
mkdir Desk3
...
Move or copy icons from Desk1 to other Desk folders as desired.
Step3 - Create bash script to switch Desks.
With your favourite text editor, create switch-desk in your $HOME folder.
Code: Select all
#!/bin/bash
#This script changes Workspace with custom Desktop Icons and Background
#Workspace behaviour is unchanged.
#
xdotool set_desktop $(($1-1))
BG=$(gsettings get org.cinnamon.desktop.background picture-uri)
Desk=$(readlink ~/Desktop)
ln -sfn $BG $Desk/background
Desk=~/Desk$1
ln -sfn $Desk ~/Desktop
BG=$(readlink $Desk/background)
gsettings set org.cinnamon.desktop.background picture-uri $BG
gsettings set org.nemo.desktop desktop-layout 'false::false'
gsettings set org.nemo.desktop desktop-layout 'true::false'
#end of script
Install xdotool if you don't already have it.
Step 4 - Make keyboard shortcuts.
Note that switch-desk requires a Desk identifier as its first and only argument.
Open Keyboard utility and select Shortcuts tab.
Select category Custom Shortcuts
Add Keyboard shortcuts. e.g.,
"Home Desktop" with command ~/switch-desk 1 and binding Alt+1
"Work Desktop" with command ~/switch-desk 2 and binding Alt+2
"Games Desktop" with command ~/switch-desk 3 and binding Alt+3
Replace "~" with explicit path to your home folder. I.e., "/home/yourname". It won't work with "~" or "$Home".
(Also, I tried binding with the Super/Windows key, but it didn't work right)
Step 5 - Test!
Note 1
When a parameter is changed via gsettings, affected systems update immediately.
The GNOME database changes over time. I found that when I upgraded from Linux Mint 19.1 to 19.3, I had to change some of the schema paths.
Note 2
The default Desktop is just a normal folder whose contents are displayed as icons on a Workspace. The default path/location of Desktop is configured in ~/.config/user-dirs.dirs. If you run into problems, make sure that Desktop remains pointing to $Home/Desktop. The fact that $Home/Desktop is now a symbolic link is not a problem.
Note 3
Perhaps you prefer using the ctl-alt-arrow keys approach to switching workspaces. In that case, you might want to add two more scripts: switch-desk-left and switch-desk-right. I preferred to leave the ctl-alt-arrow functionality untouched and instead use alt-left for switch-desk-left and alt-right for switch-desk-right. You can work out how to add the shortcuts based on Step 4 above.
switch-desk-left
Code: Select all
#!/bin/bash
#This script changes Workspace as if you pressed ctl-alt left-arrow
#Resulting Workspace has its own Desktop Icons and Background
#Workspace behaviour is unchanged.
#
DeskLeft=$( xdotool get_desktop )
if [[ $DeskLeft -gt 0 ]]
then ~/switch-desk $DeskLeft
fi
#end of script
Code: Select all
#!/bin/bash
#This script changes Workspace as if you pressed ctl-alt right-arrow
#Resulting Workspace has its own Desktop Icons and Background
#Workspace behaviour is unchanged.
#
DeskMax=$(xdotool get_num_desktops)
DeskCurrent=$(($(xdotool get_desktop)+1))
if [[ $DeskMax -gt $DeskCurrent ]]
then ~/switch-desk $(($DeskCurrent+1))
fi
#end of script
FINALLY
... I'd like some feedback if you tried this. Some acknowledgement of its usefulness will help others decide whether it will work for them.