I accidentally messed up my menu, and firefox now no longer appears when I search for applications, and I don't have a way to mark it as 'favourite' when the application is running.
I've relegated to just start firefox with the terminal, but it's a bit of a pain because I have to keep it open, and shows a lot of error output.
Is there a way to tell apt, or dpkg or some other tool to restore the icon?
I don't know what you did ("accidentally messed up my menu" is pretty vague), but I suspect that you if you reinstall Firefox, it should be re-added to your menu.
If that doesn't work, try:
This should reinstall the
/usr/share/applications/firefox.desktop
file, hopefully re-adding it to your menu.you can also do this with dconf, procedure is almost the same but this is a little easier. I think you have to at least one thing added to your favorites before they will show up here. I don't use the default desktop (i hate it), I use flashback, so I am not sure if that behavior is the same... Flashback already had default favorites when I did these commands..
list your favorites:
gsettings list-recursively | grep favorite
org.gnome.shell favorite-apps ['ubiquity.desktop', 'thunderbird.desktop', 'org.gnome.Nautilus.desktop', 'rhythmbox.desktop', 'libreoffice-writer.desktop', 'snap-store_ubuntu-software.desktop', 'yelp.desktop']
that's the line you want... if you don't see an "org.gnome.shell favorite-apps" line, add a favorite and try it again.
firefox.desktop should still actually be on your machine at /usr/share/applications/firefox.desktop
So all you have to do is add it to the end of your favorites line with gsettings, with the entire line "[INSIDE QUOTES]".
gsettings set org.gnome.shell favorite-apps "['ubiquity.desktop', 'thunderbird.desktop', 'org.gnome.Nautilus.desktop', 'rhythmbox.desktop', 'libreoffice-writer.desktop', 'snap-store_ubuntu-software.desktop', 'yelp.desktop','firefox.desktop']"
It appears on my machine immediately..... and ones that I leave off of the line, it removes them from the desktop immediately... So make sure to copy your old line correctly... maybe copy it to a text file while you are working with it for safe keeping.
If you really messed up and somehow deleted your /usr/share/applications/firefox.desktop file. You will have to make another one. This worked for me:
create a file with a text editor, I used vi.
sudo vi /usr/share/applications/firefox.desktop
...i actually called it poop.desktop, you can actually call it what you want and use that name in the gsettings assignment...which is good to know for creating future launcherspaste in the text:
[Desktop Entry]
Encoding=UTF-8
Name=Mozilla Firefox
GenericName=Web Browser
Comment=Browse the Web
Exec=firefox %u
Icon=firefox.png
Terminal=false
Type=Application
Categories=Application;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;
StartupNotify=True
save it
Try this. Download an Icon. Then,go to /usr/share/applications/firefox.desktop
nano /usr/share/applications/firefox.desktop
and search for Icon and edit it as,
Icon=/path/to/icon