Skip to content
devkoriel
Go back

How to Create Desktop Launcher in Ubuntu

Updated:
2 min read Edit on GitHub

Dependencies


How to Create Desktop Launcher


1. Create icon image

Let’s make .icons directory at /home/<user-name> with following commands.

$ mkdir ~/.icons && xdg-open ~/.icons

If .icons folder opens, put the icon image in it like below.

2. Create .desktop file

The second step is to create .desktop file for your applications then edit it. It has to follow some predefined formats. But you don’t have to worry about it at all. I’ll show you the precedures step by step and even the examples.

First, let’s move to /usr/share/applications and make .desktop file with following commands.

$ cd /usr/share/applications && gedit <application-name>.desktop

Customize the code

Change to your real application’s name.

Then gedit editor window will open and you have only to type the followings. If done, just save it.

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Sample Application Name
Comment=A sample application
Categories = Application Category
Exec=application
Icon=application.png
Terminal=false
LineDescription
[Desktop Entry]The first line of every desktop file and the section header to identify the block of key value pairs associated with the desktop. Necessary for the desktop to recognize the file correctly.
Type=ApplicationTells the desktop that this desktop file pertains to an application. Other valid values for this key are Link and Directory.
Encoding=UTF-8Describes the encoding of the entries in this desktop file.
Name=Sample Application NameNames of your application for the main menu and any launchers.
Comment=A sample applicationDescribes the application. Used as a tooltip.
Categories=Application CategoryCategories the application belongs to.
Exec=applicationThe command that starts this application from a shell. It can have arguments.
Icon=application.pngThe icon name associated with this application.
Terminal=falseDescribes whether application should run in a terminal.
VariableAccepts
%fa single filename.
%Fmultiple filenames.
%ua single URL.
%Umultiple URLs.
%da single directory. Used in conjunction with %f to locate a file.
%Dmultiple directories. Used in conjunction with %F to locate files.
%na single filename without a path.
%Nmultiple filenames without paths.
%ka URI or local filename of the location of the desktop file.
%vthe name of the Device entry.
[Desktop Entry]
Version=1.0
Type=Application
Name=QGroundControl
Icon=/home/daniel/.icons/qgroundcontrol.png
Exec=/home/daniel/files/qgroundcontrol/qgroundcontrol-start.sh %f
Comment=QGroundControl
Categories=Utility;
Terminal=false
StartupWMClass=qgroundcontrol

Tips for Desktop Entry Specification

See Desktop Entry Specification for official specifications for .desktop entries and that page also includes a link to Registered Categories.

3. Make .desktop executable

The third step is to make .desktop entry executable. The following command will do it.

$ sudo chmod +x /usr/share/applications/<application-name>.desktop

All the steps complete. If the setting isn’t applied, reboot the system then check it out.


Edit on GitHub
Share this post on:

Previous Post
GCC, G++ 다른 버전 추가하고 패키지 관리하기
Next Post
GNOME을 위한 드롭다운 터미널, Guake