How to create a desktop entry in linux
Create a file in ~/.local/share/applications
that ends in the .desktop
extension.
Here’s an example file, called anaconda_prompt.desktop
:
[Desktop Entry]
Name=Anaconda Prompt
Comment=Gnome Terminal with anaconda environment variables set.
Exec=gnome-terminal -- bash -c 'source ~/software/anaconda3/bin/activate; exec bash;'
Icon=~/icons/anaconda_prompt.png
Type=Application
Categories=Development;
Notice:
- Categories is semicolon deliminated (but I just have one)
- Exec is what executable file to launch (and it’s arguments)
- I launch a gnome-terminal
- Which executes bash, which gets its commands as argments (rather than from stdin or a file, where bash usually gets it’s commands from)
- I launch a gnome-terminal
Note: This works on any desktop environment that obliges by the freedesktop.org desktop specification, which gnome does.