Adding A New Desktop Shortcut

Create a new text file called yourname.desktop in the /home/pi/Desktop/ directory, e.g. /home/pi/Desktop/yourname.desktop

It should contain the following:


[Desktop Entry]
Name=My Name
Comment=My application which does this
Icon=/usr/share/pixmaps/openbox.xpm
Exec=/usr/bin/leafpad
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;

 

Name – The name you want displayed

Comment – Your comment

Icon – A file to use for the icon.  Your own or have a look in the /usr/share/pixmaps/ directory for something suitable.

Exec – The executable (can include sudo if your executable uses the IO). Can be the name of an executable program, or more complex, e.g. Exec=lxterminal –command "less /root/README.TXT"

Executing A Command In LX Terminal

The following will open LX terminal, wait for 5 seconds and then it will close:



[Desktop Entry]
Name=Name to be shown on desktop
Comment=My comment
Icon=/usr/share/pixmaps/openbox.xpm
Exec=lxterminal -t "Tile to display" -e sleep 5
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;

LX Terminal will auto close once the command is complete.  You can't give more than 1 command in the -e launch options (you can't give it "-e dosomething ; sleep 5" for instance as a way to make it hold showing the result after dosomething. 

Stopping The LX Terminal Auto Closing Or Doing Multiple Things

The simple way to get round the Lxterminal only being able to take one command is to have it run a bash script.

The .desktop file

[Desktop Entry]
Name=Name to be shown on desktop
Comment=My comment
Icon=/usr/share/pixmaps/openbox.xpm
Exec=lxterminal -t "Sending Crack The Code MAIN Leader Board To Internet" --working-directory=/home/pi/projects/scripts/ -e ./myscript.sh 
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;
The .sh script

#!/bin/bash

echo "Starting upload of database"
read dummy
echo "next"
mysqldump -h localhost -u user1 -p123456789 mydatabase tbl_universities | mysql -h mydomain.com -u user1 -p123456789 mydatabase
echo "Complete. Press return to exit"
read dummy

Remember to set the files permissions so it is executable (right click > properties in the file manager)

 

 





USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.

Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

  • Frank Slade

    Yo thanks holmes this tutorial is dope, made a shortcut for NetSurf works fine now.

  • For other newbies (I resemble that remark), here is a quick solution that makes life easier. I created a desktop shortcut:
    [Desktop Entry]
    Name=Python 3 – root
    comment=Integrated Development environment for Python 3
    TryExec=/usr/bin/idle3
    Exec=sudo idle3
    icon=/usr.share/pixmaps/idle3.xpm
    Terminal=false
    Type=Application
    StartupNotify=true

    Create it with the text editor and save it to ‘home/pi/Desktop’. I shave mine as idle3Plus. Now when it executes, it will run the ‘sudo idle3’ command to launch as a root. Then you can use the gpio libraries and debug without needing to keep s separate terminal window open.

  • dfrag

    how do you create a link to a location on the hard drive. I tried the following but it didn’t work.
    [Desktop Entry]
    Type=link
    Name=www
    Comment=Link to the www folder
    Exec=%u
    URL=/var/www/

    I have also tried without the Exec line and it still doesn’t work.

  • Mc Ondo

    This will open file manager into /etc

    [Desktop Entry]
    Type=Application
    Name=Open folder
    Icon=system-file-manager
    Name[en_GB]=File Manager
    GenericName=File Manager
    GenericName[en_GB]=File Manager
    Comment=Browse the file system and manage the files
    Comment[en_GB]=Browse the file system and manage the files
    Categories=FileManager;Utility;Core;GTK;
    TryExec=pcmanfm
    Exec=pcmanfm /etc
    StartupNotify=true
    Terminal=false
    MimeType=x-directory/normal;inode/directory;

  • Carol

    it is possible to have The Pi Store downloads show up on desktop or in the Menu if I’m using Raspbian OS?

  • gcolbourn

    I’ve tried this but when I open them, they just open the text file for editing! How does it turn into a desktop shortcut?

  • Melrick Nicolas

    save it as .desktop