I also wrote another tutorial on extending the functionality to include themes. See:
Switch Workspaces with own Desktop Icons, Background and Theme
viewtopic.php?p=2453348#p2453348
I prefer this current tutorial as I personally am not interested in the overhead involved with changing themes every time the desk is switched.
New update 2024 Mar 28: Turns out that the Desktop is the English name of the Desktop folder. Other languages have different names, such as Bureau in French. This Tutorial and scripts have been updated to automatically account for this.
New update 2022 Nov 23: tested today with Linux Mint 21.x Cinnamon. No changes required to scripts.
This tutorial (updated 2022 Mar 6) is written for Linux Mint 20.x Cinnamon, Mate and XFCE and describes how you can have Workspaces with different backgrounds and desktop icons. This tutorial also describes how to add shortcuts that allow you to navigate Desktops/Workspaces quickly.
When implemented as written, you can press alt-3, for example, to directly switch your display to Workspace 3 with all of its open applications. Desktop icons are switched to what is available in the Desk3 folder and the Background is changed to what you last selected while in Workspace 3. From Workspace 3, you can use alt-right(arrow) to switch to Workspace 4 or alt-left to switch to Workspace 2.
So, what do you need to do?
I am not a programmer any more; I like to write scripts. So the steps below are pretty simple. If you want more details, refer to "Appendix: How does it work?", below.
[Step1 - Change Desktop to a symbolic link. Preserve original Desktop folder contents in Desk1.
Note: What I am calling Desktop may have a different name if your language is not English. This step automatically finds the right name and location of your Desktop.
Note: Desktop appears to be "magical" in that it will reappear if moved/removed. So move and link in one line.
cd ~
Desk=$(xdg-user-dir DESKTOP)
mv $Desk Desk1; ln -sfn Desk1 $Desk
You can verify at this step that Desktop behaves as it always has - nothing is broken!
Step 2 - Create folders for other Desks.
Be careful not to re-create Desk1!
mkdir Desks
mkdir Desk2
mkdir Desk3
...
Move or copy icons from Desk1 to other Desk folders as desired.
Step 3 - Create switch-desk, a bash script to switch Desks.
With your favourite text editor, create switch-desk in your $HOME/bin folder.
switch-desk for Cinnamon
Code: Select all
#!/bin/bash
#Switch Workspace to $1 Workspace with its own Background and Desktop icons
cd ~/Desks #The Desks folder keeps the backgrounds for each Desk
DeskN=$(($(awk '{print $NF}' <<< $(xprop -root -notype _NET_CURRENT_DESKTOP))+1))
echo "$(gsettings get org.cinnamon.desktop.background picture-uri)" > "BG$DeskN"
ln -sfn Desk$1 $Desk #Make Desk$1 the new Desktop
wmctrl -s $(($1-1)) #Use wmctrl to switch Workspace (N.B., 1st workspace is 0)
gsettings set org.nemo.desktop desktop-layout 'false::false'
gsettings set org.nemo.desktop desktop-layout 'true::false'
read -er BG < "BG$1" #BG will contain the contents of BG$1
gsettings set org.cinnamon.desktop.background picture-uri "$BG" #Change the background
#end of script
Code: Select all
#!/bin/bash
#Switch Workspace to $1 Workspace with its own Background and Desktop icons
cd ~/Desks
DeskN=$(($(awk '{print $NF}' <<< $(xprop -root -notype _NET_CURRENT_DESKTOP))+1))
echo "$(gsettings get org.mate.background picture-filename) " > "BG$DeskN" #save the current background path
ln -sfn ~/Desk$1 $(xdg-user-dir DESKTOP) #Make Desk$1 the new Desktop
wmctrl -s $(($1-1)) #Use wmctrl to switch Workspace (N.B., 1st workspace is 0)
read -er BG < "BG$1" #BG will contain the contents of BG$1
gsettings set org.mate.background picture-filename $BG
gsettings set org.mate.background show-desktop-icons false
gsettings set org.mate.background show-desktop-icons true
#end of script
Note that XFCE already has per Workspace backgrounds. Only need to add per Workspace icons.
Code: Select all
#!/bin/bash
#Switch Workspace to $1 Workspace with its own Background and Desktop icons
cd ~
Desk=$(xdg-user-dir DESKTOP) #Fetch location of Desktop.
ln -sfn Desk$1 $Desk #Make Desk$1 the new Desktop
wmctrl -s $(($1-1)) #Use wmctl to switch Workspace (N.B., 1st workspace is 0)
killall xfdesktop
xfdesktop #xfdesktop needs to be restarted
#end of script
Step 4 - Add two more scripts to switch workspaces left and right
switch-desk-left for Cinnamon, Mate and XFCE
Code: Select all
#!/bin/bash
#Change Workspace as if you pressed ctl-alt left-arrow
#Resulting Workspace has its own Desktop Icons and Background
#
DeskLeft=$(wmctrl -d | grep -F '*' | cut -c1-1)
if [[ $DeskLeft -gt 0 ]]
then ~/switch-desk $DeskLeft
fi
#end of script
Code: Select all
#!/bin/bash
#Changes Workspace as if you pressed ctl-alt right-arrow
#Resulting Workspace has its own Desktop Icons and Background
#
DeskMax=$(wmctrl -d | wc -l)
DeskCurrent=$(($(wmctrl -d | grep -F '*' | cut -c1-1)+1))
if [[ $DeskMax -gt $DeskCurrent ]]
then ~/switch-desk $(($DeskCurrent+1))
fi
#end of script
Step 5 - Make keyboard shortcuts.
The following is for Cinnnamon; Mate's is similar but different. With Mate, you may be averse to using Alt+# because it conflicts with Caja shortcuts. Choose your own shortcut bindings according to your own preferences.
Open Keyboard utility and select Shortcuts tab.
Select category Custom Shortcuts.
Add custom shortcuts for navigating by workspace number. e.g.,
"Home Desktop" with command /home/yourname/bin/switch-desk 1 and binding Alt+1
"Work Desktop" with command /home/yourname/bin/switch-desk 2 and binding Alt+2
"Games Desktop" with command /home/yourname/bin/switch-desk 3 and binding Alt+3
Easiest and safest way to enter a command is to use the search tool on the right of the command text entry box to navigate and select the desired command. In my case, I have a Home partition and my path is not as shown above.
Of course, choose your own labels for your Workspaces.
Add custom shortcuts for navigating with the arrow keys:
"Desk Right" with command /home/yourname/bin/switch-desk-right and binding Alt+right
"Desk Left" with command /home/yourname/bin/switch-desk-left and binding Alt+left
I chose to leave the ctl-alt-left and ctl-alt-right shortcuts alone. Those shortcuts will continue to work as before. I.e., when changing workspaces, backgrounds and Desktop icons are unchanged.
How to Change Desktop Background
Use the standard Linux method to change the Background.
On any workspace move your cursor to an empty area on the desktop and right click to open the desktop menu. Select the menu item that changes the background. Select a picture you might like and watch the background change. You can also add your own folders and select from them. Once you have your new background, switch to another desktop and return to the original desktop. The background on the original desktop will be the new one you had just selected.
Enjoy!
Note that there is a little quirk that you should be aware of. You cannot cut from one Desktop and paste into another after switching. (You can try, but it will fail.) Instead cut/copy/paste between Desks.
This tutorial is derived from my post [Solved] Customize background and Desktop Icons for Workspaces (viewtopic.php?f=208&t=322439). As I learned more, I kept improving that post. But I finally decided it makes more sense to write it up as a tutorial.
Please let me know by private message if you have suggestions on improving the tutorial or the solution.
Appendix: How does it work?
It helps to understand a few things. The default Desktop folder in your home directory is just a normal folder but it is where the display manager finds the icons it will display. One strategy others have used is to replace the Desktop folder contents with the contents of another folder. But, it's faster and simpler, as implemented above, to change the Desktop folder to a link to another folder.
Another thing to know is the operation of gsettings, a tool that operates on the GNOME database. The GNOME database is a repository of parameters used by various Linux implementations. I have not explored it fully, but when a parameter is changed, Linux will accommodate. In particular, I found that when the parameter org.cinnamon.desktop.background is changed, the background for the active Cinnamon Workspace is changed. So, I save a link to the desired background for a given Workspace in the corresponding Desk folder and the "switch-desk" script knows where to find it. I also found that is necessary to "bounce" the org.nemo.desktop desktop-layout parameter using gsettings in order for the display manager to update the display of Desktop icons. To change backgrounds in the first place, navigate to the Workspace and select a background using the default Background switcher, easily found by opening the Mint menu and start typing "background" in the search box. Subsequently, I found how to accomplish the same goals in Mate.
By the way, the GNOME database changes over time. I found that when I upgraded from Linux Mint 19.1 Cinnamon to 19.3, I had to change some of the schema paths. However, if there were any changes, I have not noticed them over the past few versions.
Getting back to how does it work: the "switch-desk" script switches to the selected Workspace, gets the current background via gsettings and saves its link in the current Desk (not changed yet). At this point, the script links Desktop to the selected desk. Then, with gsettings, the script sets the background and desktop layout.
Feature Request
I opened a Feature Request with Linux Mint Cinnamon developers on github to suggest that my solution be incorporated into Linux Mint. It was almost immediately closed because a primary developer believes that my solution may conflict with the way Ctrl-Alt-arrow functionality works. The concern is primarily with multiple monitors, 3-D acceleration and unusual device driver behaviours.
See
Support Customization of Workspaces with different Backgrounds and Desktop Icons
https://github.com/linuxmint/cinnamon/issues/10919
I suspect there may not be enough bandwidth for developers to explore all of the issues that might arise due to possible conflicts. So, if you have any contributions, observations or comments to make on this Feature Request, please add it here or on github, as you see fit.
.