I have an application with the default icon which I don't like, I want to enforce the icon I wish. I can change the .desktop file and set the Icon value to use my icon. But the problem is: whenever the application gets an update, it replaces the .desktop file to reflect changes (new Exec path, etc.).

I need a way to make my Linux system to somehow monitor this .desktop file for changes, and overwrite the Icon field in the file whenever it changes. Is there any way to not to do it manually?

  • What Linux system are you using? the usual way to handle this would be to copy and modify the .desktop file (somewhere like ~/.local/share/applications/ for example) such that it is unaffected by updates to system files – steeldriver Sep 26 '19 at 17:59
  • @steeldriver I'm on Fedora 30 (Gnome/Wayland). I did not want to create a duplicate .desktop just to change one field, so I thought maybe there was a better solution to this? – Albert Sep 26 '19 at 18:14

linux has a feature called inotify that can execute an arbitrary process when a given path changes. You could use it together with incron (there are actually several daemons available to handle the task of picking up the kernel notifications from inotify, incron is one of the older) to run eg a sed command against that file when it changed.

you have to be careful not to get stuck in an infinite loop on this. I think incron has an option not to loop when the program executed is still running, that's meant to combat this purpose.

Another option you might consider is to get a sed command working for fixing the file, then add it into your login or session startup scripts. It's a lot less faffing about, and still from what I can see would happen in time for the change to be picked up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.