How to create desktop shortcut for running a command?

Asked by Sorrakritch

How to create desktop shortcut to run a command as below?

sudo $HOME/ldoce/ldoce

Please help

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Sorrakritch
Solved:
Last query:
Last reply:
Revision history for this message
Bhavani Shankar (bhavi) said :
#1

Hello

       1. Right click on your desktop.
       2. Select Create Launcher.
       3. In the drop down box at the top of the dialog, select Application in terminal
       4. Give the launcher a name.
       5. Browse the the executable you want to run

Revision history for this message
Craig Huffstetler (xq) said :
#2

I can't help you create a desktop shortcut, but I can help you create a terminal "alias."

Once in your home folder, create a file called:
.bash_aliases

(You can do this by typing:
touch ~/.bash_aliases
Or just by creating it in Gnome Editor or by nano perhaps:
nano ~/.bash_aliases
)

Within this file you can write a line:

Now open the file and add this line:

alias ldoche='sudo $HOME/ldoce/ldoce'

Save the file.

Every time you type "ldoche" in this example, on the command-line, it will call the command 'sudo $HOME/ldoce/ldoce'

Revision history for this message
Craig Huffstetler (xq) said :
#3

And Bhavi has given you the rest of what you need ;-)

Revision history for this message
Craig Huffstetler (xq) said :
#4

1) Find the program in the Applications menus and right click
2) Select 'Add this launcher to desktop'
3) A link to the application will now be on your desktop
4) You can also add a launcher to the panel, this is basically what the quick start was in Windows

You should also be able to do this given the information I gave you for the alias. You have the command you want to use. Make that into a "Launcher," but have it launch in a terminal window.

Revision history for this message
Sorrakritch (sorrakritch) said :
#5

Thanks all of you guys,

I've found the final solution by mixed up all of your suggestions as below:

After created the shortcut on my desktop linked to my real application at $HOME/ldoce/ldoce
edit the shortcut manually by adding some information like this...

*************************************************************
[Desktop Entry]
Name=LONGMAN Dictionary of Contemporary English
Comment=LONGMAN Dictionary of Contemporary English
Exec=kdesu $HOME/ldoce/ldoce
Path=$HOME/ldoce/
Icon=$HOME/ldoce/application/icon.xpm
StartupNotify=true
Terminal=false
X-KDE-SubstituteUID=false
*************************************************************

p.s. I'm using KDE, so I've changed the Exec command from sudo... to kdesu... instead.

Thanks to you all :-)