If you like me like to have icons on desktop but sometimes need to just hide everything to better concentrate on what you’re doing you may like this little bash script I came out with. (warning: this post applies only to gnome)
Verify you have gconf2 installed. Do that with:
sudo apt-get install gconf2.
You need a folder where to store this script (along with other scripts maybe), so make one or just use your home folder. So, open this folder and create an empty file. Call it toggle_desktop.sh or something like that. Open it with gedit and paste this text in the file.
#!/bin/bash if [ $(gconftool-2 --get /apps/nautilus/preferences/show_desktop) == "true" ]; then echo "disabling desktop" gconftool-2 --type boolean --set /apps/nautilus/preferences/show_desktop "false" else echo "enabling desktop" gconftool-2 --type boolean --set /apps/nautilus/preferences/show_desktop "true" fi; # nautilus may crash ( !#£%$$@à###!!!! ) echo "checking if nautilus is still up" sleep 1 if [ $( ps xa | grep nautilus | grep -v grep ) -z ]; then echo "nautilus is not up or crashed. Restarting nautilus" nautilus -n & echo "everything done." else echo "all good - finishing job" fi;
Done ? Save it and close gedit. Right click it, choose properties, then permissions and mark the file as executable.
Now all you need to do is double click it to hide or show your desktop icons. You may want to drag the file to your panel to access it more easily:
Note: There are a few shortcomings.
- The first is that when you hide your icons, you cannot anymore right click on the desktop. Nor changing desktop background works, it will get applied when you show your icons again.
- The second thing is that while hiding your desktop is quite fast showing it again may take 1 second or two and your window manager may become unresponsive in the meantime.
- Third thing to keep in mind: sometimes nautilus just crashes. I’ve included a quick check in the script to restart it. Nautilus crashing means it could just wipe (close) away all you’re opened file browsers. In my tests I’ve never one file browser wiped away, but it could happen. Nothing dangerous, only annoying.