Linux comes with three instructions for builders, sysadmins and customers to arrange a hierarchy of functions, usually displayed as a menu. In different phrases, these instructions enable third-party software program so as to add menu objects that work for all desktops. As well as, it permits Linux system directors to edit menus in a method that impacts all desktops utilizing the next instructions to put in and edit desktop recordsdata on Linux to make Desktop entries:
Commercial
- desktop-file-edit command is a software for enhancing desktop recordsdata.
- Use the desktop-file-install command to put in .desktop recordsdata.
- Replace database of desktop entries cache utilizing the update-desktop-database command.
- Validate desktop entry recordsdata utilizing desktop-file-validate command.
What’s desktop entry?
Common desktop environments like KDE and GNOME observe desktop entry requirements. It defines config file syntax a few specific program launched and the way it seems in menus. For instance, say I compiled and put in an app referred to as foo. Then I can outline desktop entry about it.
Location of .desktop file
All such config recordsdata have a .desktop extension, and you will discover them within the following location:
- The default Linux distro particular functions – /usr/share/functions/
- Third social gathering particular functions – /usr/native/share/functions/
- Consumer particular functions – ~/.native/share/functions/
Use the ls command to record these file:$ ls -l /usr/share/functions/
# Depend ALL .desktop recordsdata utilizing the wc command #
$ ls -l /usr/share/functions/ | wc -l
Pattern .desktop file
Right here is an instance of .desktop file construction for “Startup Disk Creator” app displayed utilizing the cat command or extra command on my Ubuntu Linux desktop:$ cat /usr/share/functions/usb-creator-gtk.desktop
Pattern outputs (I added feedback for ease of understanding):
[Desktop Entry] ## The title of the applying ## Identify=Startup Disk Creator GenericName=Startup Disk Creator ## A remark which act as a tooltip ## Remark=Create a startup disk utilizing a CD or disc picture ## The executable of the applying with non-compulsory args ## ## You may state full path too ## Exec=usb-creator-gtk ## State the title of the icon that can be used to show this entry ## Icon=usb-creator-gtk ## Is it a terminal app? For instance htop can be set as Terminal=True ## ## Then default terminal app can be used to open the 'htop' ## Terminal=false ## The sort as listed ## Sort=Utility ## States the classes during which this entry needs to be proven menu ## Classes=System;Settings;GTK;HardwareSettings; X-Ubuntu-Gettext-Area=usbcreator
Creating desktop file on Linux
For demo function I’m going to create a brand new file referred to as gpass.desktop as follows within the present listing referred to as “$HOME”/desktop-entries utilizing a textual content editor. Right here is my pattern file displayed utilizing the cat command:$ cat ~/desktop-entries/gpass.desktop
Pattern outputs:
[Desktop Entry] # App title Identify=gpass in LXD # Remark Remark=Outdated password supervisor # Is it terminal or GUI app? Terminal=false # Command to run Exec=/snap/bin/lxc exec gui-1804-gimp -- sudo --login --user vivek /usr/native/bin/gpass # Icon file Icon=/house/vivek/desktop-entries/gpass-icon.png # Classes Classes=Utility;Safety; # The sort as listed Sort=Utility
Utilizing desktop-file-edit command
As an alternative of a textual content editor, one can use desktop-file-edit as follows to construct entries. First, create an empty file named gimp-2.8.desktop utilizing the contact command:$ contact gimp-2.8.desktop
Then, run desktop-file-edit command as follows:$ desktop-file-edit
--set-name="GIMP on LXD"
--set-comment="GIMP 2.8 with customized plugins"
--set-icon="/house/vivek/backups/desktop-entries/gimp.png"
--add-category="Graphics;2DGraphics;RasterGraphics;GTK;"
--set-key="Exec" --set-value="/snap/bin/lxc exec gui-1804-gimp -- sudo --login --user vivek /usr/bin/gimp-2.8 %U"
--set-key="Sort" --set-value="Utility"
gimp-2.8.desktop
Understanding desktop-file-edit choices
Command possibility | Description |
---|---|
--set-key=KEY | Set the KEY key to the worth handed to the following –set-value possibility. An identical –set-value possibility is necessary. |
--set-value=VALUE | Set the important thing specified with the earlier –set-key choice to VALUE. An identical –set-key possibility is necessary. |
--set-key="Exec" --set-value="/snap/bin/lxc exec gui-1804-gimp -- sudo --login --user vivek /usr/bin/gimp-2.8 %U" | Set an exec path |
--set-key="Sort" --set-value="Utility" | Set app kind to “Utility” |
--set-name="GIMP on LXD" | Set the software tip |
--set-comment="GIMP 2.8 with customized plugins" | Set the remark |
--set-icon="/house/vivek/backups/desktop-entries/gimp.png" | Set the ICON path |
--add-category="Graphics;2DGraphics;RasterGraphics;GTK;" | Set the app class |
set up and edit desktop recordsdata on Linux (Desktop entries)
First, validate your desktop entries utilizing the desktop-file-validate command. For instance:$ desktop-file-validate ~/desktop-entries/gpass.desktop
Then set up the file utilizing the desktop-file-install command, run:$ desktop-file-install --dir=~/.native/share/functions ~/desktop-entries/gpass.desktop
Lastly, replace the database, run:$ update-desktop-database ~/.native/share/functions
To entry the overview at any time, click on the Actions button, or simply transfer your mouse pointer to the top-left sizzling nook. You can too press the Tremendous key in your keyboard and sort:gpass
Summing up
And that’s how we arrange desktop entries, and it’ll work with KDE, GNOME and different desktops so long as your surroundings is following XDG Desktop Entry specification. Strive it out. Do test the next handbook pages for more information utilizing the man command:$ man desktop-file-validate
$ man desktop-file-install
$ man update-desktop-database
$ man desktop-file-edit