Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 1119  / 2 Years ago, sat, march 12, 2022, 11:43:03

I have a .desktop app that runs a shell script, this shell script runs a python code when the app is double-clicked, and i want to be able to launch it from all the directories on my laptop and to keep the icon stable even if the directories of the image or icon or app was changed!


How can i make my app global?


More From » python3

 Answers
1

As apparent from the answer of Zany_Zachary suggested, launchers in /usr/share/applications are available for all users. Launchers under ~/.local/share/applications are available for the current user only. When the launcher is in these places, it will be picked up by your desktop menu or launcher. The location /usr/share/applications is a directory in use by the software management system APT of the operating system, so, although it would work, you should not place your custom .desktop files there. Instead, use the folder /usr/local/share/applications. That folder does not exist by default on Ubuntu, so you may need to create it first.


This is how "global" from your title is most readily understood. However, in your question, you suggest that under "global" you understand also something as "portable", i.e., it should continue to work even if the icon or app changed location. Still, you have to obey the conventions of the operating system where to place your icon or executable. So there is no such thing as a "global" .desktop launcher that keeps working irrespective of where you place icon or executable.


There are limits in this "portability". For one thing, the name of the icon or from the executable cannot change, because the name is hardcoded in the .desktop file. However, you can omit the path from the .desktop file, but then, you have to place icon and executable in specific places searched by the operating system.


The icon


The icon is defined in the .desktop file on the Icon= line.


If you only provide the name of the icon (without the extension), the operating system will search ~/.icons and ~/.local/share/icons first, and then search the system wide icon directories mostly under /usr/share/icons and /usr/local/share/icons. A graphics file with .png or .svg extension in one of these folders will be picked up by the menuing system. If no corresponding graphic file is found, the system will revert to a default fallback icon.


The application


The executable is defined in the .desktop file on the Exec= line.


Also here, the system will search predefined paths for an executable a the matching name if no full file path is provided. You can see the folders and their order in which they are searched with the echo $PATH command.


[#2708] Sunday, March 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kneducator

Total Points: 226
Total Questions: 111
Total Answers: 108

Location: Mexico
Member since Sun, Jul 25, 2021
3 Years ago
;