Show/Hide Desktop Icon On Ubuntu

I like things on my laptop to be simple and easily accessible. From time to time, I download stuffs. Some tutorial files, new products to test, deb updates, and several other random stuffs. Most of the time, I just throws this trashes to my desktop to make me easily remember that I have this particular stuff to work with. The other stuffs I throw to my desktop is, ebooks. Most of it is references and cheat-sheet.

As time goes by, my desktop look messed up with several files there grouped together in some corner, directories in another corner, and some other random stuffs in another corner. It came to a point where I need this Hide Desktop Icon‘s that Microsoft Windows has. It’s weird that gnome doesn’t have it built in. Several blog mentioned how to hide desktop using gconf-editor. Good, there’s a key in gnome’s registry to show/hide desktop icon. But, I don’t want to do it this way. It’s just too troublesome to walk through the path in order to change the key’s value.

I need another solution. Because I can’t find that particular solution that I needed, that means either I have to stop looking and use this tedious solution or write my own solution. And this is the fun part! Living in the free world IS fun and having total freedom to your desktop is FUN too. So, without further ado, here’s the solution I made.

  1. open up your favorite text editor
  2. Enter this snippet:
    #!/bin/bash
    
    
    current_status=`gconftool-2 --get /apps/nautilus/preferences/show_desktop`
    echo "Current Status: " $current_status;
    
    if $current_status; then
    	echo "Disabling desktop icon...";
    	gconftool-2 --type boolean --set /apps/nautilus/preferences/show_desktop false;
    else
    	echo "Activating desktop icon...";
    	gconftool-2 --type boolean --set /apps/nautilus/preferences/show_desktop true;
    fi;
    	
  3. Save it to your /home/{your_user_name}/bin/switch_desktop_icon
  4. Load up your terminal and type:
    chmod 700 /home/{your_user_name}/bin/switch_desktop_icon

    to make this script as executable

  5. Right click on your panel (the one where Applications || Places || System menu resides) and click on Add to Panel…
  6. In Add to Panel…‘s window, select Custom Application Launcher and click Add
  7. In Create Launcher window enter the Name with Show/Hide Desktop Icon(s). The Command with /home/{your_user_name}/bin/switch_desktop_icon. Choose the icon you like, then click on OK
  8. That’s it. Now, we have an easy to access show/hide desktop icon‘s command.

Author: Arief Bayu Purwanto

Hello, my name is Arief Bayu Purwanto, a 24 years old father of a beautiful daughter. Interested in online programming, linux, games, and reading. Currently working on kapanlagi.com as junior developer. I live in a relatively quite and cool place called Malang. I'm available for some freelance stuff as well as some consulting job. You can see my portofolio for some previous task I've finished and some other information related to my capability. Btw, I'm plurking here.

  • Lama ndak make Ubuntu… oh indahnya….

    silent:Ah, si om satu ini. Desktop jerawatan gitu kok dibilang indah ;))

  • Lama ndak make Ubuntu… oh indahnya….

    silent:

    Ah, si om satu ini. Desktop jerawatan gitu kok dibilang indah ;))

  • Ebiwari

    Tanks alot.I never Ubuntu could do this

  • Ebiwari

    Tanks alot.I never Ubuntu could do this

  • Lucas

    Hi,
    Great Tip! I’ve added a couple more lines to do away with all the top and bottom panels. Setting the size to 0 is only necessary once, and then should be commented out. I have to restart nautilus in order to get my desktop icons back. I’m not sure why this is.

    -Lucas
    #!/bin/bash

    current_status=`gconftool-2 –get /apps/nautilus/preferences/show_desktop`
    echo “Current Status: ” $current_status;

    if $current_status; then
    echo “Disabling desktop icon…”;
    gconftool-2 –type boolean –set /apps/nautilus/preferences/show_desktop false;
    gconftool-2 –type boolean –set /apps/panel/toplevels/bottom_panel_screen0/auto_hide true;
    gconftool-2 –type boolean –set /apps/panel/toplevels/top_panel_screen0/auto_hide true;
    gconftool-2 –type integer –set /apps/panel/toplevels/bottom_panel_screen0/auto_hide_size 0;
    gconftool-2 –type integer –set /apps/panel/toplevels/top_panel_screen0/auto_hide_size 0;
    else
    echo “Activating desktop icon…”;
    gconftool-2 –type boolean –set /apps/nautilus/preferences/show_desktop true;
    gconftool-2 –type boolean –set /apps/panel/toplevels/bottom_panel_screen0/auto_hide false;
    gconftool-2 –type boolean –set /apps/panel/toplevels/top_panel_screen0/auto_hide false;
    nohup nautilus &
    fi;

    • I have to restart nautilus in order to get my desktop icons back. I’m not sure why this is.

      Yeah, this happened sometimes. I don’t know why. Sometime it switch icon fast, sometime, I need to wait for a couple of minutes just to get the desktop icons back.

  • Lucas

    Hi,
    Great Tip! I’ve added a couple more lines to do away with all the top and bottom panels. Setting the size to 0 is only necessary once, and then should be commented out. I have to restart nautilus in order to get my desktop icons back. I’m not sure why this is.

    -Lucas
    #!/bin/bash

    current_status=`gconftool-2 –get /apps/nautilus/preferences/show_desktop`
    echo “Current Status: ” $current_status;

    if $current_status; then
    echo “Disabling desktop icon…”;
    gconftool-2 –type boolean –set /apps/nautilus/preferences/show_desktop false;
    gconftool-2 –type boolean –set /apps/panel/toplevels/bottom_panel_screen0/auto_hide true;
    gconftool-2 –type boolean –set /apps/panel/toplevels/top_panel_screen0/auto_hide true;
    gconftool-2 –type integer –set /apps/panel/toplevels/bottom_panel_screen0/auto_hide_size 0;
    gconftool-2 –type integer –set /apps/panel/toplevels/top_panel_screen0/auto_hide_size 0;
    else
    echo “Activating desktop icon…”;
    gconftool-2 –type boolean –set /apps/nautilus/preferences/show_desktop true;
    gconftool-2 –type boolean –set /apps/panel/toplevels/bottom_panel_screen0/auto_hide false;
    gconftool-2 –type boolean –set /apps/panel/toplevels/top_panel_screen0/auto_hide false;
    nohup nautilus &
    fi;

    • I have to restart nautilus in order to get my desktop icons back. I’m not sure why this is.

      Yeah, this happened sometimes. I don’t know why. Sometime it switch icon fast, sometime, I need to wait for a couple of minutes just to get the desktop icons back.

  • Hiding desktop disables right click action on desktop anyone tried a fix on this?

  • Hiding desktop disables right click action on desktop anyone tried a fix on this?

  • kai

    Hi! Thanks for working this out, it work great for me. I following Lucas’ suggestion to restart nautilus (both setting show_desktop true and false kills my nautilus process – this on a Debian Lenny system btw.), I use “nohup nautilus -n > /dev/null” because I don’t want to open a new nautilus window.

    hemanth, I think restarting nautilus is also what you need to do to enable right click actions again.

  • kai

    Hi! Thanks for working this out, it work great for me. I following Lucas’ suggestion to restart nautilus (both setting show_desktop true and false kills my nautilus process – this on a Debian Lenny system btw.), I use “nohup nautilus -n > /dev/null” because I don’t want to open a new nautilus window.

    hemanth, I think restarting nautilus is also what you need to do to enable right click actions again.

  • ongamesite

    Hi every friends,

    Did you like play online flash games and nice VIDEO ^_^. OK ! If you are interesting with it.

    Just do a click http://www.ongamesite.com. Good luck.

    Internet games,Computer games,Windows games and nice video

  • Pingback: Asignar una combinación de teclas para ejecutar un Script | Ayuda Linux()

  • Mohamed Tarek

    Thank You !