141

Possible Duplicate:
How can I edit/create new launcher items in Unity by hand?
How can I create launchers on my desktop?

I want to add some shell scripts in my launcher as shortcuts..

They are located deep inside and i have to navigate to it every time to execute them...

I tried this link where the 2nd answers seems to solvee it but as said in comments neither can i find any option to add a launcher..

I guess it existed in 11.04 with a "+" button on launcher but i use 12.04.

So how do i get this working?? And i need those commands everytime for sure..!

3
  • 2
    Relevant link, the right click for creating launcher is now gone, askubuntu.com/questions/64222/…
    – Mateo
    May 23, 2012 at 23:10
  • If you find that you can't run scripts even after checking these answers, check out this link; users running other flavors of ubuntu like Linux Mint, Mate, Xubuntu, etc may need to do sudo ln -s /usr/bin/mate-terminal /usr/bin/gnome-terminal, I was never able to execute anything in a terminal from a launcher without that.
    – jrh
    Jun 11, 2019 at 18:57
  • Use alacarte askubuntu.com/questions/281293/…
    – Rexcirus
    Apr 28, 2022 at 11:47

2 Answers 2

206
  1. Create *.desktop file, location depends on if it is for personal use or all users. If these directories do not exist, create them.

For personal use , ~/.local/share/applications

gedit ~/.local/share/applications/name.desktop

For all users, /usr/local/share/applications/ (or /usr/share/applications/ depending upon your system).

sudo -i gedit /usr/share/applications/name.desktop
  1. Paste below text

    [Desktop Entry]
    Type=Application
    Terminal=true
    Name=unmount-mount
    Icon=/path/to/icon/icon.svg
    Exec=/path/to/file/mount-unmount.sh
    

    edit Icon= and Exec= and Name=

    Also Terminal=True/false determines whether the terminal opens a window and displays output or runs in the background

  2. put this in unity panel by dragging it from files manager

logic is very simple that unity panel allows *.desktop files as launcher though I haven't tried it because I use Natty.

21
  • 2
    @Nirmik whether you use Terminal=true or Terminal=false it can always start gui(actually *.jar file in JVM). Terminal=false just hides terminal and script executes in background. May 24, 2012 at 9:34
  • 17
    How can this possibly be the correct answer in 2019?! I mean it does work, but really, i'm trying to add a shortcut to a GUI...
    – Tom
    Apr 5, 2019 at 21:29
  • 2
    Works like a charm... Ubuntu 18 LTS, Gnome Jan 9, 2020 at 12:50
  • 2
    This doesn't work in Ubuntu 19.10
    – rubo77
    Feb 20, 2020 at 10:15
  • 2
    Works in Ubuntu 20.04 LTS as well May 1, 2020 at 21:25
49

What @vipara said is mostly correct, except that I also found /usr/local/share didn't work for me. Also, you will need to run sudo update-desktop-database after adding this file in order to refresh the launcher apps. Also, there is a much easier way to create the .desktop files. First, make sure you have the gnome-panel installed (it was pre-installed on my 12.04 Ubuntu):

sudo apt-get install --no-install-recommends gnome-panel

Once you have this command, then you can run:

gnome-desktop-item-edit ~/Desktop/ --create-new

This will bring up a nice GUI window where you can select the application, icon, etc. It will dump the .desktop file on your desktop (or wherever you direct it), so you'll still need to sudo mv it to the applications folder and update the desktop database afterwards

Launchers are saved in /home/myusername/.local/share/applications

9
  • 2
    An Ubuntu 13.10, you don't have to do anything extra like you mentioned, gnome-desktop-item-edit does it for you, and it appears on you desktop automatically.
    – xchg.ca
    Nov 8, 2013 at 18:09
  • Sorry for the late reply : I've tried with IntellijIdea shell script, which I added into classpath, but in the desktop icon file WE MUST PUT THE ABSOLUTE PATH !
    – loloof64
    May 13, 2014 at 6:44
  • In Ubuntu 14.x gnome-desktop-item-edit isn't pre-installed. After creating the desktop configuration file, just drag it to the launcher (Dock). (You can also select a custom icon: right-click the desktop configuration file, select Properties ..., click on the icon in the dialogue, select an image file.) Jul 21, 2014 at 9:33
  • 1
    On 18.04 I get errors after running sudo update-desktop-database and the icons don't show up in the dock: Error in file "/usr/share/applications/org.gnome.font-viewer.desktop": "font/ttf" is an invalid MIME type ("font" is an unregistered media type) Error in file "/usr/share/applications/org.gnome.font-viewer.desktop": "font/otf" is an invalid MIME type ("font" is an unregistered media type)
    – Mitch
    Apr 30, 2018 at 7:37
  • 3
    Got gnome-desktop-item-edit: command not found after sudo apt-get install --no-install-recommends gnome-panel & gnome-desktop-item-edit ~/Desktop/ --create-new on ubuntu 20.4
    – Lawhatre
    Jun 6, 2021 at 9:47

Not the answer you're looking for? Browse other questions tagged .