My system is Ubuntu 22.04.4; GNOME Shell v42.9
The application is HomeBank, installed via flatpak. The files have an extension .xhb
. I want to associate the icon of this application to this file type.
I found the application logo files under /usr/share/icons/hicolor/ZxZ/apps/homebank.png
. The available sizes (= Z
) are 16, 22, 24, 32, 48, 256. There was no scalable .svg
icon, but I have built one.
A Google search brought up this answer from AskUbuntu. Iβll list what I did step by step. The OP wanted a custom icon for application/x-hwp
files. I want it for application/x-homebank
files.
1. Edited
/etc/mime-types
to add the line:application/x-homebank xhb
I confirmed the MIME type by right-clicking on a
.xhb
file β Properties in Nautilus.2. Created an
mimetypes/
directory under/usr/share/icons/gnome/scalable/
.3. Copied the scalable icon as below:
sudo cp /path/to/icon/application-x-homebank.svg /usr/share/icons/gnome/scalable/mimetypes/
4. Restarted GNOME with
Alt
+F2
βr
.
Icons did not change in nautilus.
Found another answer to a similar question on AskUbuntu again. The OP wanted to add custom icons for MATLAB files and figures. Hereβs what I did:
1. Created the following XML file
~/homebank.xml
:<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="application/x-homebank"> <comment>Homebank data file</comment> <glob pattern="*.xhb"/> <icon name="application-x-homebank"/> </mime-type> </mime-info>
This format is also written in the docs of
xdg-mime
command.2. Ran the following:
sudo xdg-mime install --novendor ~/homebank.xml
This added the following file in
/usr/share/mime/application/x-homebank.xml
:<?xml version="1.0" encoding="utf-8"?> <mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-homebank"> <!--Created automatically by update-mime-database. DO NOT EDIT!--> <comment>Homebank data file</comment> <glob pattern="*.xhb"/> <icon name="application-x-homebank"/> </mime-type>
This probably shows that
xdg-mime
worked fine.3. Painstakingly installed the icons, for each of the available sizes listed above, as follows:
sudo xdg-icon-resource install --novendor --noupdate --context mimetypes --size 48 homebank_48.png application-x-homebank
The above step also created symlinks. The directory structure of
/usr/local/share/icons/hicolor/
is like this:βββ 16x16 β βββ apps β β βββ ... β βββ mimetypes β βββ application-x-homebank.png β βββ gnome-mime-application-x-homebank.png -> application-x-homebank.png βββ 22x22 β βββ mimetypes β βββ application-x-homebank.png β βββ gnome-mime-application-x-homebank.png -> application-x-homebank.png βββ 24x24 β βββ apps β β βββ ... β βββ mimetypes β βββ application-x-homebank.png β βββ gnome-mime-application-x-homebank.png -> application-x-homebank.png βββ 256x256 β βββ apps β β βββ ... β βββ mimetypes β βββ application-x-homebank.png β βββ gnome-mime-application-x-homebank.png -> application-x-homebank.png βββ 32x32 β βββ apps β β βββ ... β βββ mimetypes βββ 48x48 β βββ apps β β βββ ... β βββ mimetypes β βββ application-x-homebank.png β βββ gnome-mime-application-x-homebank.png -> application-x-homebank.png βββ scalable βββ mimetypes βββ application-x-homebank.svg βββ gnome-mime-application-x-homebank.svg -> ./application-x-homebank.svg
The last directory
scalable/
was added by me manually becausexdg-icon-resource
doesnβt support scalable icons by default. I did this with:sudo mkdir scalable cd scalable sudo mkdir mimetypes cd mimetypes sudo cp ~/path/to/scalable_icon.svg ./application-x-homebank sudo ln -s ./application-x-homebank.svg ./gnome-mime-application-x-homebank.svg
4. Then ran
sudo xdg-icon-resource forceupdate
5. Restarted Gnome shell.
Nothing. Absolutely no change.
Came across this question on Unix-Linux SE, decided to give it a go. Ran the following:
update-mime-database ~/.local/share/mime
sudo update-mime-database /usr/share/mime/
update-icon-caches ~/.local/share/icons
sudo update-icon-caches /usr/share/icons/
sudo update-icon-caches /usr/local/share/icons/
No change.
Also did:
sudo cp ./application-x-homebank.svg /usr/share/icons/gnome/scalable/mimetypes/
sudo gtk-update-icon-cache /usr/share/icons/gnome/ -f
sudo gtk-update-icon-cache /usr/share/icons/hicolor/ -t
sudo gtk-update-icon-cache /usr/local/share/icons/hicolor/ -t
but in vain.
Also tried logging out and in between each of the sections above. Rebooted too. But yeah, the issue persists.
I am at a loss at this point. If anyone knows a way to make this work, I would be grateful.