Making a Desktop Entry in Linux

Making a Desktop Entry in Linux

By Ph03nix | Linux for Newbies | 21 Aug 2025


In Linux we can make buttons to execute commands on the desktop and not just scripts.

A .desktop file is a configuration file used to define application entries in the GNOME and other desktop environments. It allows users to launch applications from their menu without compiling them every time. Here is a breakdown:


#!/usr/bin/env xdg-open
[Desktop Entry]
Name=
Exec=
Icon=
Terminal=
Type=
StartupNotify=


#!/usr/bin/env xdg-open

This line specifies the interpreter or program that will execute the script. xdg-open is part of the freedesktop.org specification and is used to open files, URLs, etc. The env command ensures that the correct path to xdg-open is found regardless of the current environment (e.g., if it's installed in /usr/bin, /usr/local/bin, etc.).

 


[Desktop Entry]

This marks the start of the desktop entry metadata. All keys and values under this section are considered part of the application definition.


Name=

Specify the name of the application as displayed in the menu.


Exec=

Defines the command to execute when the application is launched.

Exec=xdg-open https://example.com

would open a URL with the default web browser.



Icon=

Points to the icon file associated with the application.


 

Terminal=

 Indicates whether the application should run in a terminal window.


Type=

Specifies the type of desktop entry 


StartupNotify=

Determines if a notification should be displayed when the application starts.


 

Here is an example

 
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=My Application
Exec=xdg-open https://example.com
Icon=myicon.png
Terminal=false
Type=Application
StartupNotify=true

When the user clicks on the entry, it will open the specified URL with their default web browser, display an icon, and show a startup notification.


  • You can just open terminal
  • Go home

cd

  • Go to Desktop

cd Desktop

  • Make the file

touch "My Application.desktop"

  • Open it with a text editor and paste it in.
  • Change permissions with 

chmod +x "My Application.desktop"

  • Now you should be able to double click and execute it.

How do you rate this article?

3


Ph03nix
Ph03nix

I am and ethical hacker with years of experience, and many certifications.


Linux for Newbies
Linux for Newbies

This blog will be dedicated to the introduction of Linux in a manner that is easy to understand for even those who are not tech savvy.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.