Gnome Desktop defines a file which describes an application. These description results in the icons and starters of applications in Gnome Desktop.
So if you want to add an custom application or an script as own application icon you have to write a custom .desktop file.
Your user specific .desktop-files are stored in ~/.local/share/applications
.
Using gnome-desktop-item-edit
Gnome Desktop delivers a simple tool to create a desktop file called “gnome-desktop-item-edit”. You can use it from console:
mkdir -p ~/.local/share/applications gnome-desktop-item-edit --create-new ~/.local/share/applications/myapp.desktop
Writing by hand
If you have special requirements, you will create your file by hand. Just open your favorite text editor and create a new .desktop file with for example the following content:
#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Terminal=true Exec=/home/user/vpn.sh Name=VPN Icon=network-vpn
This will create an application icon which starts a custom script (/home/user/vpn.sh
) in an own terminal window.
Icons can be found in directory /usr/share/icons
or you can reference a full path to any icon file.
If you use Terminal=true
, you will see that the running terminal window is matched to the normal terminal windows and not to your application icon. To solve this you can use a custom Window Manager class and start your script with gnome-terminal
and your custom class.
#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Exec=gnome-terminal --class=VPNConnection --name=VPN -- /home/user/vpn.sh Name=VPN Icon=network-vpn StartupWMClass=VPNConnection
More options and also a description of the here used ones can be found in the Desktop Entry Specification.