11

I have a shell script (studio.sh that launches Android Studio) and a png icon.

How do I use these to create a new application launcher icon for Ubuntu 22.04 such that it will show up in "Show applications" menu, and searches in the "Activities" search bar.

Thanks!

Scorb
  • 602
  • 5
  • 27
  • 50

1 Answers1

13
  1. Create a text file with a .desktop extension in your ~/.local/share/applications directory, for example ~/.local/share/applications/studio.desktop

  2. Include at least the following lines, which tell the desktop how to launch the application.

     [Desktop Entry]
     Name=Android Studio
     Exec=studio.sh
     Type=Application
     Icon=studio
    
    • This assumes that the executable, studio.sh, exists somewhere in your search path, e.g. in ~/.local/bin or in ./bin. Else, provide the full pathname to the executable script, e.g. Exec=/home/user/path/to/studio.sh.
    • This assumes that the icon is called studio.png and that the icon is in a standard place, e.g. ~/.local/share/studio.png. Else, provide the full pathname to the icon file, e.g. Icon=/home/user/path/to/studio.png.
    • If the script does not launch a graphical application, but instead should run in a terminal emulator, include a line Terminal=true.

A valid .desktop file in a valid location, with a valid command on the exec= line will automatically, within seconds, appear in your menu system and be searchable.

More fields are available. Study some files under /usr/share/applications to see how it works.

vanadium
  • 82,909
  • 6
  • 116
  • 186
  • Thanks for this answer, this is really useful. I have a follow up question; after locating the application via Activities search bar, once I open it, it appears on the sidebar launcher, but how can I add to the favorites so that it remains in the sidebar? When I right click that app, I don't see add to favorites. – user3138373 May 31 '23 at 14:39