Setting an icon to kicad files

Hello!
I’m trying to setup icons to kicad file types. At present, they show as follows, and I would appreciate
if the project file at least could have an easily identifyable icon. Anything would be fine. Here is how
a specific project folder looks like.
Screenshot from 2021-05-22 11-06-41
I’m using Ubuntu 20.10. Kicad 5.99.
I don’t know exactly what I’m doing, so I thought it might be better to ask… I read on the subject and i’ts apparently related to mime types.
I have checked file /usr/share/mime/packages, and there are 2 kicad-related files.
kicad-gerbers and kicad-kicad, both xml.
All other applications have a single name. (e.g, codeblocks.xml, not codeblocks-codeblocks.xml). Is this a bug?
In the kicad-kicad file, there is apparently nothing to set an icon, so I checked other websites, and found out that there is a file called mime.types in /etc. But again, this seems to be only for extensions. There is no kicad in the whole file, is it related to my problem? If I want to add kicad-related inpo, should it be something like application/kicad? Or application/vnd/kicad? Something else?
Any pointer would be nice.

Thanks,

1 Like

/etc/mime.types relates to an older association method according to this rather old how-to:

https://help.ubuntu.com/community/AddingMimeTypes

You seem to already have the mapping from file suffix to mime type but you need to associate an SVG icon with that type.

Edit: I would also search to see if there are user defined locations for the mapping files because if you edit a system defined location they may be wiped out on upgrade.

Managing mime types manually under linux is a big *&^%$#@!
The link that retiredfeline posted is among the best I’ve seen yet.
I had a look at:

/usr/share/mime/application

but I see nothing for KiCad there.
I do see an entry for KiCad-nightly V5.99 in:

/usr/share/applicatations

Now I’m getting quite annoyed because that *&^%$#@ file manager can not even manage to show file names. For some *&^%$#@! reason it hides file extensions.
… And apparently it hides much more. what is this “org.kicad” prefix???

paul@medion:/usr/share/applications$ ls -hl *night*
lrwxrwxrwx 1 root root 72 May 17 10:36 org.kicad.bitmap2component-nightly.desktop -> ../kicad-nightly/applications/org.kicad.bitmap2component-nightly.desktop
lrwxrwxrwx 1 root root 64 May 17 10:36 org.kicad.eeschema-nightly.desktop -> ../kicad-nightly/applications/org.kicad.eeschema-nightly.desktop
lrwxrwxrwx 1 root root 64 May 17 10:36 org.kicad.gerbview-nightly.desktop -> ../kicad-nightly/applications/org.kicad.gerbview-nightly.desktop
lrwxrwxrwx 1 root root 61 May 17 10:36 org.kicad.kicad-nightly.desktop -> ../kicad-nightly/applications/org.kicad.kicad-nightly.desktop
lrwxrwxrwx 1 root root 69 May 17 10:36 org.kicad.pcbcalculator-nightly.desktop -> ../kicad-nightly/applications/org.kicad.pcbcalculator-nightly.desktop
lrwxrwxrwx 1 root root 62 May 17 10:36 org.kicad.pcbnew-nightly.desktop -> ../kicad-nightly/applications/org.kicad.pcbnew-nightly.desktop
paul@medion:/usr/share/applications$ cat org.kicad.kicad-nightly.desktop 
[Desktop Entry]
Version=1.0
Terminal=false
Icon[fr]=kicad
Icon=kicad-nightly
Type=Application
Categories=Science;Electronics;
Exec=kicad-nightly %f
MimeType=application/x-kicad-project;
Name[de]=KiCad (nightly)
Name[el]=KiCad (nightly)
Name[en]=KiCad (nightly)
Name[es]=KiCad (nightly)
Name[fi]=KiCad (nightly)
Name[fr]=KiCad (nightly)
Name[it]=KiCad (nightly)
Name[ja]=KiCad (nightly)
Name[pl]=KiCad (nightly)
Name[ro]=KiCad (nightly)
Name[ru]=KiCad (nightly)
Name[sv]=KiCad (nightly)
Name[tr]=KiCad (nightly)
Name[zh_CN]=KiCad (nightly)
Name[zh_TW]=KiCad (nightly)
Name=KiCad (nightly)
GenericName[de]=EDA Suite (nightly)
GenericName[el]=Σουίτα EDA (nightly)
GenericName[en]=EDA Suite (nightly)
GenericName[es]=Suite EDA (nightly)
GenericName[fi]=EDA Suite (nightly)
GenericName[fr]=Suite CAO Electronique (nightly)
GenericName[it]=Suite EDA (nightly)
GenericName[ja]=EDAスイート (nightly)
GenericName[pl]=EDA Suite (nightly)
GenericName[ru]=САПР (nightly)
GenericName[tr]=EDA Paketi (nightly)
GenericName[zh_CN]=EDA 工具箱 (nightly)
GenericName[zh_TW]=EDA 工具箱 (nightly)
GenericName=EDA Suite (nightly)
Comment[en]=Suite of tools for schematic design and circuit board layout (nightly)
Comment[fr]=Suite d’outils pour la conception schématique et des circuits imprimés (nightly)
Comment=Suite of tools for schematic design and circuit board layout (nightly)
X-Desktop-File-Install-Version=0.22

But more importantly, I have not made those files myself. They were put there by KiCad’s installation procedure. Maybe you made an error during installation, or it may be some kind of bug.
A few weeks ago there was an error in the mimetype thing which caused all kicad-nightly entries to be removed from the start menu. That was reported and fixed within a few days.

1 Like

Shouldn’t KiCAD add the mimetypes for its extensions when installing? Currently all KiCAD files are mimetype text/plain and will open in whatever text-editor you have configured to be default. That’s kind of annoying actually.
I found this: https://unix.stackexchange.com/questions/564816/how-to-install-a-new-custom-mime-type-on-my-linux-system-using-cli-tools
Could this be done automatically in the installation process or when running KiCAD the first time?

KiCad does add the MIME types for its files when you install it on Linux - so I would suggest reporting this issue to the packager of KiCad on your distribution so that they can fix it in their setup.

Hello!

Shouldn’t KiCAD add the mimetypes for its extensions when installing?

Yes it should. On the other hand, it’s not a crucial issue, it works without icons.
I’m looking at ways to do that right now. Basically what would help me is to have
icons for:

  • The project file
  • PCB file
  • Sch file
    I read about mime types, etc, and I think that’s one way to do it, although slightly geeky.
    Could anubody tell me the difference between the files with extensions .pro and .kicad_pro? Which one is the project file? Same question for extensions .sch and .kicad_sch. Apparently there is only one .kicad_pcb and no .pcb file. Is this normal?

Are there .svg files for the icons? Preferably the new Kicad6 icons.

Thanks for any hint.

Who is running the nightly PPA?

You call it “slightly geeky”, but that’s how it is on Linux. Unfortunately you can’t just assign the file extension to an icon and associate it with an app to open with, like you would do on Windows.
First you must add a MIME type for your files, then you can associate an icon and app to that MIME type. The file extension has almost no significance to that process.

Hello!

Unfortunately you can’t just assign the file extension to an icon and associate it with an app to open with, like you would do on Windows.
First you must add a MIME type for your files, then you can associate an icon and app to that MIME type. The file extension has almost no significance to that process.

Thanks for the reply, here is what I was using.
https://itectec.com/ubuntu/ubuntu-how-to-change-the-icon-for-a-particular-file-type/

But that’s not really what I was asking. In some project folder I’m looking at right now, there are files called filename.pro and filename.kicad_pro. In the meantime, I checked with a text editor, and the .kicad_pro seems to be a kind of preference file. But both start the program when double-clicked.

As for the .sch and .kicad_sch, is it a matter of old / new format?

Screenshot from 2021-05-22 11-06-41

Yes (same with pro vs kicad_pro)

See https://docs.kicad.org/master/en/kicad/kicad.html#kicad_files_and_folders for details

Hello!

Thanks for your reply. Anyway, I tried and it doesn’t work. I mean:

  • I have added new mime types because there was no kicad-related mimetype.
  • I have made svg icons that I copied to /usr/share/icons/gnome/scalable/mimetypes;
    (I have created the mimetypes folder which was missing).
    But the icons are still the same as above. I rebooted just to be sure.
    But I can’t see the svg files on Ubuntu. I created them on mac, and it displays svg
    nicely, but once copied on Ubuntu, there is only the icon name, not even a blank file
    icon.
    I think that will be about it for today, except if somebody has an idea to be tried.

Thanks,

I’m not trying to read this discussion carefully, so I just ask: have you already used update-mime-database?

Hello!

Thanks for your reply.
I tried to run updat-mime-database.
It reposts Usage: etc…
And what it says is that I need a MIME-DIR argument

I checked this manpage:

https://manpages.ubuntu.com/manpages/bionic/man1/update-mime-database.1.html

And there is not even one hint at what the MIME-DIR could be. Any idea?
I thought it might be the place where mime.types is, which is /etc. But there is no
subfolder packages.

Thanks

I assume you have installed KiCad somewhere, /usr/local/ or /opt/kicad/ or something like that. For me the 5.99 mime xml file is in /usr/local/share/mime. That’s probably the needed MIME-DIR.

1 Like

On my (Arch) machine, these mime types are defined
application/x-kicad-schematic
application/x-kicad-pcb
application/x-kicad-project

The definitions are in /usr/share/mime/application/x-kicad-schematic.xml
which looks like this:

<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-kicad-schematic">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <sub-class-of type="text/plain"/>
  <comment>KiCad Schematic</comment>
  <comment xml:lang="fr">Schéma électronique KiCad</comment>
  <glob pattern="*.sch"/>
</mime-type>

This is for v5.1.10 but it should give you some idea of what is required if you need to set up the files / associations manually for 5.99

Hello!

Thanks for your reply. In my case, the s-kicad-schemtaic.xml looks exactly the same as what you show.
By the way, how do you display a piece of xml file? The first line is missing in the previes, whatever I do. So apparently it should treat sch and kicad_sch as schematic files.

<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-kicad-schematic">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <sub-class-of type="text/plain"/>
  <comment>KiCad Schematic</comment>
  <comment xml:lang="fr">Schéma électronique KiCad</comment>
  <glob pattern="*.sch"/>
  <glob pattern="*.kicad_sch"/>
</mime-type>

Beside this, if I check the porperties of a schematic file, it’s clearly defined as Type Kicsd Schematic (application/x-kicad-schematic).

Thanks

So all you need to do is copy the files to /usr/share/icons/hicolor/SIZE/mimetypes

On my machine have
/usr/share/icons/hicolor/64x64/mimetypes/application-x-kicad-pcb.png
/usr/share/icons/hicolor/64x64/mimetypes/application-x-kicad-project.png
/usr/share/icons/hicolor/64x64/mimetypes/application-x-kicad-schematic.png

Make sure the SIZE (64x64 in the example above) matches the size you are using in your file manager. If you have svg files, you should use the scalable directory instead.
You might need to run gtk-update-icon-cache after adding the files.

1 Like

But you shouldn’t really need to jump through all these hoops. This should be handled automatically by the installer on your distribution.

Hello!
Thanks for your reply!
Sounds like an endless nightmare. I think I will wait that the installer handles it.
Thanks anyway!

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