.desktop files on Ubuntu

18th May 2023 at 1:58am

It took me a whole hour to figure how to set up a .desktop file on Ubuntu which honestly seems unnecessarily complicated. In previous versions of Ubuntu, there was a GUI (gnome-desktop-item-edit) which aided in this process but unfortunately, this appears to have been removed. Here are some useful notes to set up .desktop files

  • .desktop file format example
#!/usr/bin/env xdg-open

[Desktop Entry]
Exec=/usr/bin/gedit %U
Comment=comment here

It's a parameter for the Exec key in .desktop files (defined in the Desktop Entry Specification) that describes how arguments to the program (from the file manager/program launcher, e.g. multiple selected files) should be handled

gtk-launch something.desktop