2

If I save an executable MyApp in ~/Desktop, I can right click on the icon, select Properties from menu. In the Properties window I can now left click on the icon to open Select custom icon window. Next I double click on the required .png file to use as custom icon and close Properties window. This changes the executable's desktop icon to the selected custom .png file.

Is there a way to do the above procedure using bash shell commands?

The selected custom icon .png file doesn't appear to be saved in a MyApp.desktop file, so where is this setting saved?

vanadium
  • 88,010

1 Answers1

2

The information is saved in a binary file:

~/.local/share/gvfs-metadata/home

You can not simply edit it, but use some gio-tools:


Check the attributes of one file:

gio info file

Change attributes:

gio set file attribute value

So in your case to change the custom icon:

gio set ~/Desktop/MyApp metadata::custom-icon file:///path/to/icon.png

To remove the attribute, use -t unset:

gio set -t unset ~/Desktop/MyApp metadata::custom-icon

In earlier Ubuntu Versions (e.g. 16.04) the commands are gvfs-info instead of gio info and gvfs-set-attribute instead of gio set), but work exactly the same.

pLumo
  • 26,947