How To Fix Home Folder Icons on the Desktop
I recently installed the Snap version of Okular on my Ubuntu MATE system. When I opened and used Okular I noticed that my Home folders and files were on my Desktop. My system still worked; however, my desktop was a cluttered mess. I didn't take any screenshots, but I did search online for a solution and I found three websites that helped me fix my problem. The three websites: Okular breaking /home directories links, [SOLVED] Home folder icons shown on desktop, and home/user/Desktop and Public Folders Show as Type Link (broken) (inode/symlink).
I first recommend that you uninstall the Snap version of Okular. If you want to use Okular on your system then install the Flatpak version after you fix the broken folders in your Home folder.
Solution
You need to delete or remove the broken folders in your Home folder from your system. The image below is from user joseemilio_33 from ask Ubuntu. He had four folders in his Home folder to become corrupt. I had Desktop and Public folders corrupt on my system. You can delete the corrupt folders within your File Manager or open your Terminal and enter: rm Desktop Public (Only remove the corrupt folders from your system.)
Next, create a new folder or folders of the ones you deleted in your Home folder. You can create these folders in your File Manager or open your Terminal and enter: mkdir Desktop Public (Only create folders with the same names as the folders you deleted earlier.)
Next, open your Terminal and enter the following: gedit $HOME/.config/user-dirs.dirs
(You can replace gedit with your favorite text editor.)
(You can replace gedit with your favorite text editor.)
Notice in the image below that the XDG_DESKTOP_DIR and XDG_PUBLICSHARE_DIR have $HOME/ as the path for those directories. That explains why all of the files and folders from my Home folder were placed on my Desktop.
To fix this problem set XDG_DESKTOP_DIR="$HOME/Desktop" and XDG_PUBLICSHARE_DIR="$HOME/Public" and then Save the changes.
Before you reboot your system, your need to place a empty hidden file in each of the new folders you created. You can do this via the Terminal or using your File Manager. Go into one of the folders you created and turn on Show Hidden Files.
Right-Click in an empty area and highlight Create Document and scroll down and click on Empty File.
Give the file a name and start it with a period or dot (.). This will make the file a hidden file.
Repeat these steps for each new folder you created.
You can also use the Terminal to create a hidden file in each of your new folders. You can use the touch command to create a hidden and empty file in each of the new folders. My user name is tommy so you would replace tommy with your user name. Examples:
touch /home/tommy/Desktop/.sample.txt
touch /home/tommy/Public/.sample.txt
touch /home/tommy/Desktop/.sample.txt
touch /home/tommy/Public/.sample.txt
Now Reboot your system and check to see if the problem is fixed.
Feb. 14, 2024