2

I'm running Ubuntu 20.04 and installed Firefox 79 from tar file. I can now only launch from command line. I would like to create shortcut and add it to my favorites. How can this be done?

I tried steps here https://linuxconfig.org/how-to-create-desktop-shortcut-launcher-on-ubuntu-20-04-focal-fossa-linux but there is no Firefox file to copy, and there is no *.desktop file to be found anywhere.

Nmath
  • 12,333

2 Answers2

4

There were several traps here to creating a working firefox.desktop file:

  • "Allow launching" is not an option in Ubuntu 20.04.
  • The Exec= value in the desktop file must contain the full path to the Firefox executable (e.g. /home/wonko/myapps/firefox/firefox) unless the executable is somewhere on the $PATH variable.
  • The desktop file has to be placed in the ~/.local/share/applications/ directory.

Here is what I did without installing additional software, all from the command line:

  1. [Optional] Download a Firefox icon from the interwebs and save it in ~/.local/share/icons/ with the name firefox and keep the existing file extension at the end (.png, .ico, .svg, etc). By using the original filename your themes are able to change the icon.
  2. Create a firefox.desktop file at ~/.local/share/applications/
  3. Paste this into the file [change paths to suit your own config]:
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Type=Application
    Terminal=false
    Exec=/home/wonko/myapps/firefox/firefox
    Name=Firefox
    Comment=Firefox
    Icon=firefox
    Categories=GNOME;GTK;Network;WebBrowser;
    
  4. Run chmod +x ~/.local/share/applications/firefox.desktop

After a few seconds, you should see the Firefox icon in your dock or application launcher and you're good to go. You can also launch by pressing Super and typing in "Firefox".

matigo
  • 22,138
  • 7
  • 45
  • 75
3

Use the default firefox.desktop File,
Firefox is installed under snap. which means, /snap is the PATH to grab the Desktop file.

Find the correct Desktop file:
sudo find /snap/ -type f -name "firefox.desktop"
Example Output:
/snap/firefox/1232/firefox.desktop  
/snap/firefox/1232/meta/gui/firefox.desktop

We just found the firefox.desktop under the path: /snap/firefox/1232/.

Copy it to your Desktop:
cp -v /snap/firefox/1232/firefox.desktop ~/Desktop/

Then, Right Click on it and Allow Launching.

Fix Icon Doesn't Appear

If the Icon doesn't appear, You just need to add the full path for the image file.
Note: The snap PATH number 1232 might change over time, so we have to copy the icon image to a different location:

cp -v /snap/firefox/1232/default256.png /usr/share/pixmaps/firefox.png

Edit firefox.desktop from your Desktop, and change the line
From: Icon=/default256.png
To: Icon=/usr/share/pixmaps/firefox.png

Benny
  • 4,920