Archives For November 30, 1999

hide or show desktop shortcuts in Ubuntu

Want an option in your desktop’s context menu (right-click menu) that hides or un-hides all your desktop shortcuts in Ubuntu Unity or Gnome?

Ramvignesh, the guy sent me two simple scripts with this great idea. If you are interested, below will show you how to do it step by step.

1. How to Create Desktop Shortcuts in Ubuntu 14.04

Due to bug, you can’t drag and drop an application shortcut icon from Unity Dash result to desktop in Ubuntu 14.04 LTS.

But it’s still easy to create a desktop shortcut, all you need to do is:

  1. Open your file browser, navigate to Computer (from left sidebar)-> user -> share -> applications.
  2. Right click on a shortcut icon and select ‘Copy’
  3. Right-click on blank area of your desktop and select ‘Paste’

Finally you’re able to click the desktop shortcut to launch the application without worrying about user permission issue.

2. Create the scripts to show/hide desktop shortcuts

Thanks to Ramvignesh for the simple scripts.

  • Create a new folder called bin in user’s Home folder.
  • Go into bin folder and create 2 empty documents: show-desktop-shortcuts, hide-desktop-shortcuts
  • Edit 2 documents one by one and paste below contents into them. IMPORTANT: Replace handbook in red with your user name.
    • for show-desktop-shortcuts file:
      #!/bin/bash
      #
      cd /home/handbook/Desktop
      for f in .* ; do 
      new=`echo "$f" | cut -c 2-`
      mv "$f" "$new"
      done
    • for hide-desktop-shortcuts file:
      #!/bin/bash
      #
      cd /home/handbook/Desktop
      for f in * ; do
      mv "$f" ".${f#.}"
      done
  • Finally make the 2 scripts executable by going to their context menu (right-click menu) -> Properties -> Permissions tab -> check the box where it says 'Allow executing file as program'.

    3. Add The 2 Scripts As Options Into Desktop's Context Menu

    Click the button below to bring up Ubuntu Software Center and install nautilus-actions, a graphical tool for configuring Nautilus' context menu.

    Now open nautilus-actions from Launcher and do:

    1. Create 2 new actions in Items list, name them to Show Desktop Shortcuts & Hide Desktop Shortcuts
    2. Under Action tab of both items, check the box says "Display item in location context menu"
    3. Type a name in Context label

    4. Under Command tab of both items, type in (browser) path to the two scripts in Path box.
    5. (Optional) Go the menu Edit -> Preferences, in first tab un-check the two boxes under Nautilus menu layout.

    Finally, your desktop's context menu will look like below after reboot.

    Enjoy!