Ubuntu 18.04 custom icon for executable saved in ~/Desktop

Hi

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?

You can use gio to retrieve this setting or change it.

Here’s an example to set a custom icon on the command line:

mkdir ~/test
gio set -t string ~/test metadata::custom-icon file:///usr/share/icons/Adwaita/scalable/mimetypes/inode-directory-symbolic.svg

double-check:

$ gio info --attributes=metadata::custom-icon test
[...cut...]
attributes:
  metadata::custom-icon: file:///usr/share/icons/Adwaita/scalable/mimetypes/inode-directory-symbolic.svg

IHowever, I don’t know how to remove the attribute in order to restore the default.
If you pass an empty string as value, then no icon will be shown in Files as the attribute is still there:

$ gio set -t string ~/test metadata::custom-icon ''
$ gio info --attributes=metadata::custom-icon test
[...cut...]
attributes:
  metadata::custom-icon: 
1 Like

It’s not very intuitive, you can unset an attribute by using unset as type:

$ gio set -t unset ~/test metadata::custom-icon
1 Like

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