Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-10-10 04:43:34

Signy
Member
Registered: 2020-10-20
Posts: 44

Mousepad - how to detect filetype from mime-type?

I have got a lot of bash scripts without an extension but with magic word:

#!/bin/bash.

Mousepad can not detect their filetype as Script - sh unless I add extension sh and I have to change filetype manually.

But mime-type is correctly detected

$ file --mime-type some_script_name
some_script_name: text/x-shellscript

I found file /usr/share/gtksourceview-3.0/language-specs/sh.lang and there are interesting lines:

    <property name="mimetypes">text/x-shellscript;application/x-shellscript;text/x-sh</property>
    <property name="globs">*.sh;*bashrc;.profile;.bash_profile</property>

- so mime-types look OK.

I added *; to the beginning of the line with globs:

    <property name="mimetypes">text/x-shellscript;application/x-shellscript;text/x-sh</property>
    <property name="globs">*;*.sh;*bashrc;.profile;.bash_profile</property>

but now Mousepad opens even regular files with mime-type text/plain as scripts.

Removing the globs line did not help - after that scripts are not detected at all.

So it seems that Mousepad ignores mime-types and uses globs only.
Is there any way how to force Mousepad to open scripts according to mime-type of files?
Or it is a GTK source view bug?
(BTW: I would not mind if Mousepad ignored globs completely and used mime-type only.)

Offline

#2 2021-10-10 07:20:18

Tamaranch
Member
Registered: 2020-12-31
Posts: 45

Re: Mousepad - how to detect filetype from mime-type?

This is fixed since Mousepad 0.5.0, current version is 0.5.7.
If your distribution does not offer a way to update Mousepad to a 0.5.x version, you can install it via Flatpak: https://flathub.org/apps/details/org.xfce.mousepad

Offline

#3 2021-10-10 08:21:28

Signy
Member
Registered: 2020-10-20
Posts: 44

Re: Mousepad - how to detect filetype from mime-type?

OK, thank you very much for info and help.
I downloaded this version (for Ubuntu Hirsute 21.04)
https://launchpad.net/ubuntu/impish/amd … 3-0ubuntu1
and it works on Xubuntu Focal 20.04 too.

The only disadvantage is its new icon, but I can downgrade it...

Last edited by Signy (2021-10-10 14:33:08)

Offline

Board footer

Powered by FluxBB