How to make so that my icon would be added to a certain file extension which is not indexed in the system?

Icon:
seal-color-reversed-c50d9b78

Extension file:
.scss

I want to make it so that for a certain non-registered type of file extension would connect my icon.

The system has no standard icons for this file extension: name_file.scss

I want to create a file with extension .scss somewhere in the system so the system will add my icon to it.

The system has a functionality to add an icon to any file. This partially solves the problem. But if you delete this file and create it back with the same file extension, the icon is not added:
Screenshot from 2023-05-22 18-21-05

Usually, the file editors do not assign icons per extension but my mime type.

You can check out the archwiki: Icons - ArchWiki

(I’ve tested it unsuccessfully, but I’m not using Gnome/KDE.)

On Gnome you open Files (Nautilus) and right click on the file and go to Properties, then click on the icon to change it

image

and in the next window you select your icon from your custom *.svg or *.png file …

1 Like

Hello, I have done this before. But I am not satisfied with the result.
When you delete this file and create it with the same name and extension, the picture is not assigned back.

The guy above advised to look into Icons - ArchWiki:

That’s what I did yesterday. As I was reading yesterday, I realized that each extension has its own MIME type registered with the system. And through this MIME-type each file extension is assigned its own icon.

Today I’m going to ask the question in a slightly different wording. I think there will be people who will answer it.

But thanks for the tip anyway. :facepunch: :handshake:

I’ve tried with your icon but I failed. However, this might be due to my setup where I’m using i3 and thunar as file explorer. There might be something broken with icons and mime types.

(It should work, however :crossed_fingers:)

I see. If anything, I asked a new question with a different wording, here is the link. If you want, you can watch it, maybe you will understand something for yourself, if I can solve this problem. :slightly_smiling_face:

Good day to all. About two days ago I asked a question.

The guy below suggested that I was interested in MIME types of file extensions. And gave a link to Icons - ArchWiki.

I started reading “Icons - ArchWiki” and after a while got to MIME-types specification. I continued to read the MIME-types specification and when I got to the section “The icon files” I tried to register a new file MIME-type with extension .scss in directory ~/.local/share/mime/packages and then I ran the command:

update-mime-database ~/.local/share/mime

but it didn’t make a difference.

I still don’t understand how to specify a link to the icon in the xml file, so that when the system detects that this ( name_file.scss ) file has the extension .scss, what would it refer to the corresponding file with the MIME type and it already gave the icon to the file with the .scss extension.

I don’t understand exactly how the whole mechanism works, described as I understand it now. I hope, that some people will help me to understand MIME file types.

I’m waiting for developers, if available and if they can suggest something. Or just at least explain the scheme of how the whole thing works.

I am waiting for anyone with good advice on the subject! :fist: :saluting_face:

=====================

P.S. and yes if you ever do something like this, be sure to take pictures via timeshift or any other program to create system restore files. During these two days I screwed up a lot and timeshift helped me out more than three times. :upside_down_face:

=====================

=====================

Links to stuff I’ve read and tried to do:
Icons - ArchWiki
MIME-types specification

=====================
XDG MIME Applications - here is some information about creating separate MIME-types for each user in the ~/.local/share/mime/ folder

Thanks to one dude’s advice from this article. For the advice to create a directory /mime/packages if it doesn’t exist:

=====================

maybe you would want to share what you tried, instead of just saying it did not work.

I was always under the impression file types were deducted from the file magic, not the extension, and this was a reason why windows style fake .extension “viruses” did not spread on linux. But by the links you posted with a quick look it seems also extensions can be defined to look some way… ?!

Commonly there is set a theme. That theme defines which icon is set for each extension and if not, there is none.

So if you want to change it, you would need to modify the theme and exchange the icon.

Get a list of your system themes:

pamac list | grep -i theme

Let’s say you have the papirus icon theme. Get the list of files:

pamac list --list-files papirus-icon-theme | grep -E "text-x-scss" 

Now you have the paths to the icon files. These have to be exchanged. Doing this on system files is a bad idea, since it will be overwritten if it gets updated, therefore copy it:

mkdir -v ~/.icons
cp -R /usr/share/icons/Papirus  ~/.icons/
find ~/.icons -iname "*scss*

And there you exchange them. However, I never needed to do so, therefore it is just the theory. Probably a relogin/reboot is needed.

Ah, right. Now i understand you want a permanent icon for those *.scss files. On KDE Plasma this process is a bit more straight forward … Anyway, here is what is best explained how to get it manually.

https://unix.stackexchange.com/questions/585997/assign-an-icon-to-a-custom-mimetype/593329#593329

Hey guys. I kind of solved the issue by installing a different icon theme. But still I will dig further, how to do it on the previous icon theme :slight_smile:
Good luck everyone! Thank you for your feedback, thanks to some of you I have broadened my horizons. Thanks.

Screenshot from 2023-05-29 15-05-03

See:

https://wiki.archlinux.org/title/Icons

Specifically:

To append a custom icon to an existing icon theme xdg-icon-resource can be used. This will resize and copy the icon to $HOME/.local/share/icons/. With this method, custom emblems can also be added. Examples:

$ xdg-icon-resource install --size 128 --context emblems archuser-example.png # add as emblem
$ xdg-icon-resource install --size 128 archuser-example.png # add as normal icon

Thank you.

Admins: Do not close the topic, I will still be working in this direction and would like to share it here as I will be able to.
But all at your discretion :slight_smile:

2 Likes