How to Easily Create Desktop Shortcuts on Raspberry Pi OS?
If you are used to other systems where creating desktop shortcuts is a breeze, this process might be a mystery to you after switching to Raspberry Pi OS. Don’t worry it isn’t very complicated, just follow the steps I will share with you in this tutorial.
If an app shortcut is available in the main menu, it’s possible to create a shortcut on the desktop with a drag & drop. If it’s a custom application not in the main menu, the only way will be to create the shortcut file (.desktop) with a text editor.
The first solution is pretty intuitive, whereas the second is almost impossible to remember. I’ll show you both in this article, with a tip to make the second easier.
Create desktop shortcuts for apps in the main menu
Creating a desktop shortcut for programs available in the main menu is straightforward: a drag & drop of the icon to the desktop will create the shortcut for you.
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
I don’t think this is available in older versions, so you might need to either upgrade (procedure here) or read the next section if it doesn’t work. But on Raspberry Pi OS Bullseye at least, you can follow this easy process:
- If you haven’t already, start by installing the application you want to add on the desktop.
- Open the main menu, and check if you can find the application somewhere.
- If you find the application, just drag and drop the icon on the desktop.
Left-click on the link in the main menu and move your mouse to your wallpaper. - You should see an icon like this added on the desktop:
- You can rename the shortcut if you want.
Hit “F2” and type the new name in the window that shows up.
That’s it! Not so complicated, isn’t it?
You can now launch the app by double-clicking on it.
Create desktop shortcuts for custom programs
This was the easy way. But, if you are here, it’s probably because you didn’t find a way for this process to work.
For example, if you installed a program that isn’t automatically added to the main menu, or even have to run a script or command in a terminal.
I will explain all of this now.
Add it in the main menu
I will take the example of PyCharm, a famous programming tool that ranked well in my best text editors here.
When you download it on the website, you get an archive file (.tar.gz).
There is a script to run to open the program after extracting the files, but it doesn’t automatically create a main menu entry (yes, there is a way, but that’s not the point today).
So, if you are in this situation (you have an app working but no desktop or main menu shortcut), here is what to do:
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
- Open the main menu, and go to Preferences > Main Menu Editor.
- This tool allows you to choose which shortcut you want in the main menu.
Just use the checkbox to enable or disable anything. - But you can also add new items:
- Pick a category (“Programming” in my example).
- Click on “Next Item” on the right.
- A window like this shows up:
Fill the form with at least the name and the executable path (in the command field).
You can click on the image icon on the left to use a custom icon. - In my example with PyCharm, it will be something like that:
- Once done, click on “OK” twice to save the changes.
- The shortcut should now be available in the main menu.
Create the desktop shortcut
From there, you can just follow the drag & drop method I previously shared. This will create the new desktop shortcut.
In fact, this is just an easy way to generate the file we’ll create manually in the last solution (without having to remember the file content).
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
Create shortcut for a script or command line
The PyCharm example
In the previous method, we have learned how to create a “.desktop” file on our Desktop to get a shortcut to open an application. Another option is to directly create this file.
Here is what it looks like:
[Desktop Entry] Comment=Run PyCharm Terminal=false Name=Pycharm Exec=/home/pi/Downloads/pycharm-community-2020.3.5/bin/pycharm.sh Type=Application Icon=/home/pi/Downloads/pycharm-community-2020.3.5/bin/pycharm.png
So, basically, you can take this example, change the parameters to fit the application you want to run, and it should work.
Help others navigate the world of Raspberry Pi with your insights.
Become a RaspberryTips Contributor!
Create your script and shortcut
I’ll show you a complete example to illustrate this manual method.
Let’s say I want to have a shortcut on my desktop to run htop.
Here is how to do this:
- Create a new file on your desktop, with a .desktop extension.
You can do this with the GUI (Right-click > New file) or with nano:nano /home/desktop/myshortcut.desktop
- Paste these lines in it:
[Desktop Entry]
Comment=Monitor Pi Usage
Terminal=true
Name=Htop
Exec=htop
Type=Application
Icon=/usr/share/pixmaps/htop.png
That’s it, it should now work directly.
If you want to run a custom script or command, you might need to run it in a terminal, by editing the “Exec” value like this:lxterminal -e <your_command>
For example:Exec=lxterminal -e /home/pi/myscript.sh
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.
Desktop entry main options
Right before we finish, here’s a table with the most common keys you can use to create the perfect desktop shortcut:
Key | Description | Values |
---|---|---|
Name | The name of the shortcut. | Ex: “My Shortcut” |
Comment | The tooltip (doesn’t work on Desktop I think). | Ex: “My App Description” |
Exec | Program to execute. | Ex: “/usr/bin/app” or command |
Icon | The path to the icon to use for the shortcut. | /path/to/icon.ext |
Type | The type of desktop entry (as listed previously). | Application, Link or Directory |
Terminal | Only for type “Application”. | true or false |
URL | Only for type “Link”. | https//domain.com |
Path | Only for type “Application”. If you need to run it in a specific folder. | Ex: “/home/pi/myapp” |
Here is a link to the complete documentation if you need more details (it’s for GNOME, but it’s similar on any desktop environment).