chmln / handlr

A better xdg-utils
MIT License
633 stars 25 forks source link

Some html files are being opened by a terminal text editor instead of their handlr default #10

Open Kabouik opened 4 years ago

Kabouik commented 4 years ago

I'm not sure what's wrong, but some html (I think only text/html) are being opened by a text editor instead of their handlr default:

~ $ handlr get text/html
firefox.desktop
~ $ ls /usr/share/applications/firefox.desktop
/usr/share/applications/firefox.desktop
~ $ handlr open TOTO.html

→ Opens with kakoune.desktop.

~ $ cat ~/.local/bin/xdg-open
#!/bin/sh
handlr open "$@"
~ $ which xdg-open
/home/kabouik/.local/bin/xdg-open
~ $ xdg-open TOTO.html

→ Same (as expected).

~/.local/share/applications/kakoune.desktop:

[Desktop Entry]

Name=Kakoune
GenericName=Text Editor
Comment=Modal text editor

Icon=kak
Type=Application
Categories=terminal;TextEditor;
Keywords=text;editor;syntax;terminal;

Exec=tilix -e kak %U
StartupNotify=false
Terminal=true
MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-
~ $ handlr list
┌─────────────────────────────────────────────┬────────────────────────────────┐
│ #x-scheme-handler/mailspring                │ mailspring.desktop             │
│ application/excel                           │ libreoffice-calc.desktop       │
│ application/msexcel                         │ libreoffice-calc.desktop       │
│ application/pdf                             │ mupdf.desktop                  │
│ application/rtf                             │ libreoffice-writer.desktop     │
│ application/vnd.ms-excel                    │ libreoffice-calc.desktop       │
│ application/vnd.oasis.opendocument.text     │ libreoffice-writer.desktop     │
│ application/vnd.openxmlformats-officedocum+ │ libreoffice-calc.desktop       │
│ application/vnd.openxmlformats-officedocum+ │ libreoffice-writer.desktop     │
│ application/x-extension-htm                 │ userapp-Firefox-XGT2G0.desktop │
│ application/x-extension-shtml               │ userapp-Firefox-XGT2G0.desktop │
│ application/x-extension-xht                 │ userapp-Firefox-XGT2G0.desktop │
│ application/x-extension-xhtml               │ userapp-Firefox-XGT2G0.desktop │
│ application/x-ms-excel                      │ libreoffice-calc.desktop       │
│ application/xhtml+xml                       │ firefox.desktop                │
│ audio/mp3                                   │ cmus.desktop, sayonara.desktop │
│ audio/mpeg                                  │ cmus.desktop, sayonara.desktop │
│ image/bmp                                   │ viewnior.desktop               │
│ image/gif                                   │ viewnior.desktop               │
│ image/jpeg                                  │ viewnior.desktop               │
│ image/jpg                                   │ viewnior.desktop               │
│ image/png                                   │ viewnior.desktop               │
│ inode/directory                             │ org.gnome.Nautilus.desktop     │
│ text/html                                   │ firefox.desktop                │
│ text/plain                                  │ kakoune.desktop                │
│ video/3gp                                   │ mpv.desktop                    │
│ video/3gpp                                  │ mpv.desktop                    │
│ video/3gpp2                                 │ mpv.desktop                    │
│ video/divx                                  │ mpv.desktop                    │
│ video/dv                                    │ mpv.desktop                    │
│ video/fli                                   │ mpv.desktop                    │
│ video/flv                                   │ mpv.desktop                    │
│ video/mp2t                                  │ mpv.desktop                    │
│ video/mp4                                   │ mpv.desktop                    │
│ video/mp4v-es                               │ mpv.desktop                    │
│ video/mpeg                                  │ mpv.desktop                    │
│ video/mpeg-system                           │ mpv.desktop                    │
│ video/msvideo                               │ mpv.desktop                    │
│ video/ogg                                   │ mpv.desktop                    │
│ video/quicktime                             │ mpv.desktop                    │
│ video/vnd.mpegurl                           │ mpv.desktop                    │
│ video/vnd.rn-realvideo                      │ mpv.desktop                    │
│ video/webm                                  │ mpv.desktop                    │
│ video/x-avi                                 │ mpv.desktop                    │
│ video/x-flc                                 │ mpv.desktop                    │
│ video/x-fli                                 │ mpv.desktop                    │
│ video/x-flv                                 │ mpv.desktop                    │
│ video/x-m4v                                 │ mpv.desktop                    │
│ video/x-matroska                            │ mpv.desktop                    │
│ video/x-mpeg                                │ mpv.desktop                    │
│ video/x-mpeg-system                         │ mpv.desktop                    │
│ video/x-mpeg2                               │ mpv.desktop                    │
│ video/x-ms-asf                              │ mpv.desktop                    │
│ video/x-ms-wm                               │ mpv.desktop                    │
│ video/x-ms-wmv                              │ mpv.desktop                    │
│ video/x-ms-wmx                              │ mpv.desktop                    │
│ video/x-msvideo                             │ mpv.desktop                    │
│ video/x-nsv                                 │ mpv.desktop                    │
│ video/x-ogm+ogg                             │ mpv.desktop                    │
│ video/x-theora                              │ mpv.desktop                    │
│ video/x-theora+ogg                          │ mpv.desktop                    │
│ x-scheme-handler/chrome                     │ userapp-Firefox-XGT2G0.desktop │
│ x-scheme-handler/ftp                        │ userapp-Firefox-XGT2G0.desktop │
│ x-scheme-handler/http                       │ userapp-Firefox-XGT2G0.desktop │
│ x-scheme-handler/https                      │ userapp-Firefox-XGT2G0.desktop │
└─────────────────────────────────────────────┴────────────────────────────────┘

Is it just a local issue on my machine or is it because the default for text/plain takes precedence for text/html?

chmln commented 4 years ago

Hi @Kabouik

Thanks for filing an issue!

This can happen if you have html files without doctype, html, body, and some other tags.

I've reported this issue upstream https://github.com/ebassi/xdg-mime-rs/issues/22 If it doesn't get resolved quickly there I will add a workaround.

Kabouik commented 4 years ago

Thanks, glad you identified the issue already. I'll keep a look on that.

tpeacock19 commented 3 years ago

@chmln do you plan on adding a workaround for this? I'm still experiencing this issue and it does not seem like it has gotten much attention upstream.