Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to quickly create a Launcher entry for a certain command, e.g. sudo <command>?

I remember older Linux (Ubuntu and others) distributions where I could right-click the panel (or desktop) and select "Create Launcher".

share|improve this question
    
Do you mean add a second command to a pre-existing Launcher entry or a new entry? –  Dennis Feb 16 '13 at 12:18
    
Adding it for a new command is sufficient. –  Mike L. Feb 16 '13 at 12:24

1 Answer 1

Unity Launcher editor

You can use Unity Laucher Editor to create and modify launcher icons using only a GUI. Keep in mind that the status of this application is experimental; expect some glitches.

To install it, run the following command from a terminal:

sudo apt-get install bzr && cd && bzr branch lp:unity-launcher-editor

Once installed, you can run it by pressing Alt + F2 and executing

~/unity-launcher-editor/ule

screenshot

Traditional approach

Create a new launcher item

  1. Install gnome-panel using the Software Center or with the command

    sudo apt-get install gnome-panel
    
  2. Press Alt + F2 and execute the command

    gnome-desktop-item-edit --create-new ~/.local/share/applications
    
  3. Depending on the application, choose either Application and gksudo <command> or Application in terminal and sudo <command>.

  4. Open Nautilus, press Ctrl + L and go to

    ~/.local/share/applications
    
  5. Drag the newly created .desktop file to the launcher.

Add a command to an existing launcher item

  1. Search for the launcher icon's .desktop file; it's usually in one one these two folders:

    ~/.local/share/applications
    /usr/share/applications
    
  2. Press Alt + F2 and execute the command

    gedit <.desktop file>
    
  3. Add the following line to [Desktop Entry].

    Actions=sudo;
    

    If an Actions= line already exists, append sudo; to it.

  4. At the end of the file, add the following:

    [Desktop Action sudo]
    Name=Run as Root
    Exec=gksudo <command>
    
  5. Save the modified .desktop file in ~/.local/share/applications. If the original file is in a different folder, remove the old launcher icon (right-click, Unlock from Launcher) and drag the new file to the launcher.

share|improve this answer
    
Thank you very much. One related question: ~/.gnome/apps also seems to contain similar .desktop files. Is this for backward compatibility? –  Mike L. Feb 16 '13 at 15:25
    
I've tried to create an item with the command gnome-desktop-item-edit --create-new ~/.local/share/applications, but unfortunately, it fails to launch. :( Other commands like gksudo truecrypt work. –  Mike L. Feb 16 '13 at 15:30
    
1. Do or did you have GNOME installed? I don't even have a ~/.gnome directory on my computer... 2. Try to run it from a terminal to see why it fails. –  Dennis Feb 16 '13 at 15:31
    
Regarding Gnome - I have the standard Ubuntu 12.04 installed, so I guess, that Gnome is not installed. Launching the command from the Terminal works fine. –  Mike L. Feb 16 '13 at 15:49
    
Interesting. I have Ubuntu 12.04 as well. Maybe some application you installed had that path hardcoded... I've edited my answer to add a GUI-based approach. –  Dennis Feb 16 '13 at 15:53

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.