2

I installed an android-studio on my machine. But I only need the emulator, not the whole android-studio.

I can run my emulator from Terminal using the following command

cd /home/bmshamsnahid/Android/Sdk/emulator && ./emulator -avd Pixel_2_XL_API_29

How can I use an icon? So I can open the Emulator by clicking the icon.

Internally, whenever I click the icon, the script will be executed.

Can you provide any guidelines or terms I can look for?

1 Answers1

1

Create a launcher file for the script. A launcher file is a text file with specific format and .desktop extension, as outlined elsewhere on Askubuntu.

The line that defines the command that must be run is the line starting with Exec=. The parser for that line is rather primitive: you only can provide it with a single command and arguments. There are a couple of ways around that:

1) Create a wrapper script containing the commands and call the wrapper script on the Exec= line

2) Launch bash with the -c argument.

For approach 2), more practical for just a few commands, your specific Exec= line would appear as:

Exec=sh -c "cd /home/bmshamsnahid/Android/Sdk/emulator && ./emulator -avd Pixel_2_XL_API_29"

Create the .desktop file in .local/share/applications if it is only for you (no root permissions needed), or in /usr/share/applications if the launcher must be available for all users. Correctly formatted .desktop files in any of these directories will automatically appear in your application menu, from where you can optionally pin it to the Dock.

vanadium
  • 88,010