Based on official documentation:
In order to add your launcher to the Unity Launcher on the left, you
select and drag it onto the Launcher panel. Alternatively, you can
place your .desktop file at /usr/share/applications/ or at
~/.local/share/applications/. After moving your file there, search for
it in the Dash (Windows key -> type the name of the application) and
drag and drop it to the Unity Launcher. Now your launcher (.desktop
file) is locked on the Unity Launcher!
It means, that you can add a launcher manually via "drag and drop".
But, is it possible to do this programatically?
I can explain why I am asking about it:
I have my own scpirt, it downloads the latest version of Eclipse IDE, creates eclipse.desktop file without iteraction with User.
And on the last step I want to add Eclipse.desktop file to Unity Launcher and I do not want to ask user to do it.
I analized the spesification for *.desktop files and did get an answer.
Please provide advice.
Best Answer
I actually made a script for that. It places the icon down in the launcher, but with a minor change, you can put it at the top (or any other position) as well.
As it is, it is in python2, but simply change the shebang to
#!/usr/bin/env python3
if you'd like to use it as python3. The code is identical.To use it, the .desktop file needs to be in either
/usr/share/applications
or in~/.local/share/applications
, but usually that is the case.How to use
launcher_add.py
Run it by the command:
you have to use the filename of the .desktop file, without the path.
The script
The script prevents multiple occasions in the launcher list of the same application, which would cause corruption of he list.