Automatically Replace Line in .desktop File

Hoping for some guidance here… This is purely cosmetic and in no way breaks my system.

I installed Brave Nightly and use the Tela icon theme, but found I really can’t stand Tela’s icon for Brave; no big deal because I can just edit Brave Nightly’s .desktop file to point to the native icon, right?

Correct, but every time Brave Nightly updates, the .desktop file is overwritten and my icon changes disappear.

My solution was to sed the replacement line; i.e.:
sudo sed -i "111 cicon=/opt/brave.com/brave-nightly/product_logo_128_nightly.png" /usr/share/applications/brave-browser-nightly.desktop

That successfully changes the line; however, the default icon—that is, /opt/brave.com/brave-nightly/product_logo_128_nightly.png—is not used and the “no icon found” icon is used instead.

I’m really kind of lost as to what could be going on here and would appreciate some other eyes on it…

Instead of modifying the file that constantly gets overwritten, copy the desktop file to ~/.local/share/applications/ and modify it there. That should override the copy in /usr/share/applications/ as long as it has the same name.

1 Like

I thought about that, @dalto, and the only reason I didn’t do that was in case the .desktop file contained an “important” change… Not likely?

Not likely. Also, if/when it does happen, it will stop working and you can just copy it again.

That being said I have being doing that for many years with multiple programs and have had that happen to me less than 5 times. Typically when the name of the software changes.

Makes sense… Thanks for the help, @dalto!

For anyone else who comes across this, I noticed an error in my original “code;” I used a lower-case “i” in “icon” rather than a capital “I” and I believe that’s where the issue was.

I believe Dalto’s recommendation to copy the .desktop file to ~/.local/share/applications is superior due to its simplicity.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.