How to Configure Desktop Launchers on Ubuntu 24 with Standard Icons
Source: Dev.to
What is a .desktop file?
- A freedesktop.org Desktop Entry – a UTF‑8 text file with a
.desktopextension. - Contains a
[Desktop Entry]group with key‑value pairs. - Three entry types are defined:
| Type | Purpose |
|---|---|
Application | Launch a program |
Link | Open a URL |
Directory | Represent a folder in menus (rarely used) |
For launchers you’ll usually use Application (and optionally Link).
The format is used by GNOME (Ubuntu’s default), KDE, XFCE, and many other desktops.
Where to put .desktop files
| Location | Purpose |
|---|---|
~/Desktop | Icons that appear on the desktop (when this is your XDG_DESKTOP_DIR) |
~/.local/share/applications/ | User‑specific menu entries (overrides system entries with the same name) |
/usr/share/applications/ | System‑wide menu entries (managed by packages; avoid editing manually) |
- Desktop launcher → place the file in
~/Desktop. - Menu‑only launcher → place the file in
~/.local/share/applications/. - You can copy or symlink the same file to both locations if you want it in the menu and on the desktop.
Required keys for an Application launcher
| Key | Description |
|---|---|
Type=Application | Declares the entry as an application launcher |
Name= | Label shown in menus and under the icon |
Exec= | Command to run (full path or name in $PATH) |
Icon= (optional) | Icon to display (see “Icon options” below) |
Comment= (optional) | Short description / tooltip |
Terminal= (optional) | true if the command must run inside a terminal |
Path= (optional) | Working directory for the command |
TryExec= (optional) | Path to the executable; used to hide the entry if missing |
Categories= (optional) | Menu categories (relevant for entries in applications/) |
StartupNotify= / StartupWMClass= (optional) | Improves task‑bar/launcher behavior |
All keys are case‑sensitive.
Minimal example
[Desktop Entry]
Type=Application
Name=My Script
Exec=/home/user/bin/my-script.sh
Save as ~/Desktop/my-script.desktop.
On some desktops you must make it executable:
chmod +x ~/Desktop/my-script.desktop
Icon options
| Form | Example | When to use |
|---|---|---|
| Theme icon name (no path) | Icon=utilities-terminal or Icon=firefox | Preferred when the icon exists in the current icon theme (/usr/share/icons/...) |
| Absolute path | Icon=/usr/share/pixmaps/ubuntu-logo.svg or Icon=/home/user/.local/share/icons/myapp.png | Use for custom icons (PNG, SVG, XPM) |
If the icon cannot be found, the desktop falls back to a default icon, but the launcher will still work.
Exec= syntax and field codes
You can pass arguments and use spec‑defined variables:
| Variable | Meaning |
|---|---|
%f | Single file path (e.g., one selected file) |
%F | Multiple file paths |
%u | Single URL |
%U | Multiple URLs |
%i | Icon name from the desktop file (for startup notification) |
%c | Localized name |
%k | Path to the .desktop file |
Example: Exec=myeditor %f opens the selected file in myeditor.
For a simple launcher with no arguments, just use a plain command, e.g. Exec=firefox or Exec=/usr/bin/gnome-terminal.
If the program needs a terminal, set Terminal=true and keep the command in Exec=:
Exec=/home/user/scripts/backup.sh
Terminal=true
Full example – Daily backup script
[Desktop Entry]
Type=Application
Name=Daily Backup
Comment=Run backup script
Exec=/home/user/scripts/daily-backup.sh
Icon=utilities-terminal
Terminal=true
Path=/home/user
- Save as
~/Desktop/daily-backup.desktop - Make it executable:
chmod +x ~/Desktop/daily-backup.desktop - Double‑clicking the icon will run the script in a terminal.
Link launcher (opens a URL)
[Desktop Entry]
Type=Link
Name=Project Wiki
Comment=Open project wiki in browser
URL=https://wiki.example.com/project
Icon=web-browser
The desktop will open the URL with the default web browser.
Common troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Launcher does not run | Wrong or missing Exec= (full path or command not in $PATH). | Verify the command works in a terminal; for scripts, ensure they are executable and add Terminal=true if needed. |
| Icon is missing | Invalid Icon= value. | Use a known theme icon name (check /usr/share/icons/Yaru/ or similar) or an absolute path to a valid image file. |
| Launcher not visible on desktop | File not in ~/Desktop, missing .desktop extension, or not executable. | Move the file to ~/Desktop, rename with .desktop, and run chmod +x. |
| Launcher not in application menu | File placed in the wrong directory. | Put the file in ~/.local/share/applications/. If a system entry with the same name exists, the user file overrides it. |
| Changes not reflected | Menu cache not refreshed. | Log out/in, or run update-desktop-database (if installed). |
Additional topics (placeholders for future guides)
- Checking your Ubuntu version
- Context‑menu differences in file managers (Nautilus, Nemo, Dolphin, Caja) for Ubuntu 24.04
- Installing Ubuntu 24.04 & useful tools
- GPU monitoring applications on Linux/Ubuntu
- Kubuntu vs. KDE Neon: a technical deep dive
- Ubuntu keyboard shortcuts cheat‑sheet
- Ubuntu package management: APT &
dpkgcheat‑sheet - Changing a static IP address in Ubuntu
(These sections can be expanded into separate articles.)
- Server
- Desktop Entry Specification (freedesktop.org)
- Desktop Entry Specification – Exec key and variables
- Icon Theme Specification (freedesktop.org)
- Desktop Menu Specification (freedesktop.org)