[Geany-Users] Wrong mimetype when opening files from Geany

Lex Trotman elextr at xxxxx
Sat Feb 20 23:17:24 UTC 2021


On Sun, 21 Feb 2021 at 05:18, D.T. <ohnonot-github at posteo.de> wrote:
>
> When I open e.g. shell scripts without any .sh extension, geany
> categorizes them as "application/octet-stream", which, afaiu, is a
> fancy way of saying "this could be anything".

The mimetype is set by the filetype from the setting in the filetype
file and "filetypes.sh" has "application/x-shellscript" in it, so what
filetype is the no-extension file opening with?
If it has a shebang it should still open as shellscript.
If it has no shebang either it will be "None" for which Geany falls
back to "text/plain" not "application/octet-stream"

In fact the text "octet-stream" does not appear in the Geany
repository, in code or any filetype file.

> This is mostly apparent in the icon assigned to the file, both in
> Geany's file browser plugin, but also in ~/.local/share/recently-
> used.xbel, an application-independent list of, well, recently used
> files. This wrong mimetype then sticks around there (other apps do not
> change it for that file once it is set).

Thats a function of your desktop system, Geany just tells GTK the
filename and some data including mime type and what happens with it is
desktop specific.

>
> When I analyse such files with 'gio info', I get 2 content types:
> ...
>   standard::content-type: application/x-shellscript
>   standard::fast-content-type: application/octet-stream
> ...
> So afaics Geany always chooses the "fast" type?
>

Geany does not use any of the various system mime type guessers to set
filetype or mimetype, they are unreliable, and you can see the one you
used gets more than one answer.  Geany sets the filetype from specific
content such as the shell shebang or from the extension to ensure its
deterministic.  And the mime type is set from that as above.

> Version 1.37.1, the issue occurs on 2 Archlinux installations and
> someone using Geany on Debian Stable (Bunsenlabs) reports not having
> that issue.
>

Since "application/octet-stream" does not exist in Geany source,
perhaps Arch is patching "text/plain" to that when they build the
package, but Debian doesn't.  The Geany project does not make
packages, there are too many distros each with their own special
rules, you would have to raise it with the Arch package maintainers.

Cheers
Lex

> I'm not a coder, but I'd be happy to get some help understanding, and
> possibly help resolve it.
>
> TIA,
>
> o.
>
>
> _______________________________________________
> Users mailing list
> Users at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list