I fixed it. The problem was that the script was using the wrong icon-theme. It should have been:
gsettings get org.mate.interface icon-theme
and not
gsettings get org.gnome.desktop.interface gtk-theme
After this change, the script worked. Icons are now correctly being shown.
The script is now also capable of uninstalling an desktop file, mimetypes and icon associated with it.