Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a launcher for an application that I just installed but whatever I searched was about creating a file with .desktop extension, but I need another way to make this without any coding or typing.

I found Arronax but it doesn't work for me. that's not launching the desired application. Arronax can make .desktop file visually by selecting needed parameters. Somebody suggest me something please.

share|improve this question
    
You mean an application currently without a launcher, right? – Jacob Vlijm Feb 6 at 11:35
    
a sort of, there is a .sh file when i do sh ./app.sh it's start the application and it has a icon in launcher when it's open but i cant keep it in launcher. – Ehsan Aghaei Feb 6 at 12:28
    
You probably need to tell a bit more about the application, which is it? A tkinter application by any chance? – Jacob Vlijm Feb 6 at 12:30
    
Hi Ehsan, did you read my question above? – Jacob Vlijm Feb 8 at 9:46
    
hi, the application is Jetbrains PhpStorm. I can't pin this to the launcher when it's open. – Ehsan Aghaei Feb 8 at 12:23

Outside sources

What you need is gnome-desktop-item-edit program. Basically it does the same thing - it creates a .desktop file. Why ? Because launchers are .desktop files, just pinned to launcher. Nothing more than that. Windows shortcuts are .lnk files too by they way, they just don't show up as files with .lnk extension, but if you ever mounted a Windows hard drive - you'll know.

The gnome-desktop-item-edit command is still available if you install gnome-panel or gnome-tweak-tool.

Once you have it, you can use this command in terminal:

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

Homebrew

I've actually written a small script for that purpose before (because why not ? ). You can copy the code, save to file, and run whenever you want it. That simple !

#!/bin/bash

FORM=$(zenity --forms \ --title="Simple shortcut maker" --text="Create new .desktop file" \
        --add-entry="Program Name" \
        --add-entry="Command or path to file" \
        --add-entry="Terminal app(true/false)" \
        --add-entry="Icon (path)") 

[ $? == 0 ] || exit 1

awk -F'|' -v home="$HOME" '{ 
    FILE = home"/Desktop/"$1".desktop"
        print "[Desktop Entry]" >> FILE
        print "Type=Application" >> FILE
        print "Name="$1 >> FILE
        print "Exec="$2 >> FILE
        print "Terminal="$3 >> FILE
        if ($4 !~ /^[ ]*$/)
            print "Icon="$4 >> FILE ;
    system("chmod 755 " FILE);

}' <<< "$FORM"

And that's how it looks:

enter image description here

You will have .desktop file in your Desktop folder, which you can later pin to launcher.

Note: the content about the gnome-desktop-item-edit is provided by fossfreedom's original answer, please upvote his good work !

share|improve this answer
    
thanks a lot for making this – Ehsan Aghaei Feb 6 at 7:52

Assuming your application is a GUI application, currently without a launcher, there is a simple way to let Unity create the launcher for you in ~/.local/share/applications, after which you can move it to anywhere you like.

  1. Run the (GUI) application a single time from command line.
  2. In the Launcher, right-click on the icon that appears, running the application, choose "lock to launcher"

    enter image description here

  3. Navigate to ~/.local/share/applications, there you'll find your new launcher, created by Unity. Even the arguments you ran it with are included in the launcher. Since it is not executable yet, it will be iconless.

  4. Make it executable (right-click in nautilus > permissions (tab), now you can move it to anywhere you like and double- click to start the application.

N.B. The name of a launcher which is not executable (yet) might differ from the name you saw in the Unity Launcher. If you doubt, simply sort the files in ~/.local/share/applications by modification date, the latest edited file is your newly created launcher.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.