After installing Matlab, I was dismayed to discover that there was no desktop-entry for it. It is sometimes annoying to open a predominantly graphical software via the terminal.
So I created a desktop-entry for Matlab on my own. A bit of a background first:
|Desktop Environment||Gnome 3.22.2|
On my particular machine, Matlab was installed at
/usr/local/MATLAB. In particular, the
/usr/local/MATLAB/R2017b/bin/ directory contains executables, like the one for actually launching Matlab.
Infact, the only way to open Matlab after installation was by running
/usr/local/MATLAB/R2017b/bin/matlab -desktop on my terminal, which is exactly what I want to avoid by creating a desktop entry for Matlab.
Creating a basic functional desktop entry was easier than I thought. There are two fundamental steps:
- Obtain an icon for the application.
- Create a desktop-entry file and place it in an appropriate location.
These steps can be tailored for creating a desktop-entry for just about any application that doesn’t have a desktop-entry by default.
Obtain an Application Icon
Theoretically, the icon can be any image file. A Matlab icon is available at https://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png.
Download the file and put it somewhere where the file is unlikely to get disturbed. I chose to put the file into the Matlab installation directory at
/usr/local/MATLAB. To do this via the command line, run:
$ cd /usr/local/MATLAB $ wget https://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png && mv Matlab_Logo.png logo.png
The second command above downloads the file into the current directory and renames it to
Create a Desktop Entry File
For a full understanding of this process, read the official Gnome documentation at https://developer.gnome.org/integration-guide/stable/desktop-files.html.
.desktop file. Pick a good descriptive name – I chose
matlab-launch.desktop. Since I’m the only user on my computer who would use Matlab, I put the
.desktop file in
The contents of my
matlab-launch.desktop are as follows:
[Desktop Entry] Name=Matlab Exec=/usr/local/MATLAB/R2017b/bin/matlab -desktop Icon=/usr/local/MATLAB/logo.png Type=Application Encoding=UTF-8 Terminal=false Categories=Development;Science;Education;
The crucial fields are:
|Exec||Program to execute; the terminal command that would open the application.|
|Icon||Path to the application icon you have saved earlier.|
I believe the rest of the fields are self-explanatory, and not all of these are required. For a detailed understanding of each of those fields, read the official documentation about this here.
Almost immediately after you save the desktop file, the Matlab icon should appear in your application menu, and clicking it should open Matlab.