chmln / handlr

A better xdg-utils
MIT License
609 stars 24 forks source link

"handlr list" doesn't fully describe decision making process. make it clearer what assumed prior knowledge is? #20

Open Dieterbe opened 3 years ago

Dieterbe commented 3 years ago

Hello,

my handlr list output is below

handlr list
┌─────────────────────────┬────────────────────────────────────┐
│ message/rfc822          │ userapp-Thunderbird-JHQ4UY.desktop │
│ x-scheme-handler/mailto │ userapp-Thunderbird-JHQ4UY.desktop │
│ x-scheme-handler/webcal │ chromium.desktop                   │
└─────────────────────────┴────────────────────────────────────┘

This seems incomplete. I know for example that a file with extention .txt will be opened by gvim (though I don't know why) When I strace handr list i see it opens lots of .desktop files in .local/share/applications and /usr/share/applications/ From what I understand, there's also custom associations that can be set in handlr as well as a separate mimetype data base. The readme mentions "Automatically removes invalid/wrong .desktop entries from mimeapps.list", I have these 3 files (see below) and it's not clear how they're used or in which priority order:

~/.config/mimeapps.list
~/.local/share/mimeapps.list
~/.local/share/applications/mimeapps.list

I know that part of the problem is that I'm uneducated on the matter, and i could probably go read the various (?) XDG/opendesktop specs that are relevant, but it seems rather confusing, so maybe there is an opportunity to steer new users in the right direction:

thanks!

chmln commented 3 years ago

@Dieterbe I've added --all to handlr list which will show all the associations, user and system :)

about something like handlr explain that says, for a given file, how it arrives at a decision?

Yeah I might add a verbose option to handlr get at some point. What do you think ?

Dieterbe commented 3 years ago

handlr list --all is helpful, and the verbose flag sounds good. thank you!

FWIW, as a user it's not necessarily clear why certain associations exist (for example when i run the new handlr list --alli have "added associations" which seem to come from desktop files in /home/dieter/.local/share/applications/, but also from /usr/share/applications/, but confusingly other files from /usr/share/applications seem to go under "System Apps", not "added associations") a quick note about where the associations come from, maybe with a link to the relevant spec, would be really useful I think.

chmln commented 3 years ago

@Dieterbe this feature is now released in v0.5 :)

Dieterbe commented 3 years ago

So, which specs should one read to understand how this tool works? I was reading the source and through https://crates.io/crates/freedesktop-desktop-entry I found out it uses the spec https://specifications.freedesktop.org/desktop-entry-spec/latest/index.html

which other ones ? https://www.freedesktop.org/wiki/Specifications/file-uri-spec/ ? https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/ ? https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.1.html ?

so far, seems mime-apps-spec is the most relevant one. Again, some guidance to users of this tool about what they should know, would be very helpful.

edit: after some reverse engineering, it seems handlr follows what mime-apps-spec says, and uses the files mentioned there. associations are maintained in $XDG_CONFIG_HOME/mimeapps.list (even when set through handlr), and not in the handlr config file. sort of stuff would be very useful to document . some more things i found out, the "selector" to choose how to open is only in case you have multiple entries on the priority mimeapps config. it doesn't let you choose if you have different choices at different priority levels.

chmln commented 3 years ago

@Dieterbe good points. If you wanna write up a quick paragraph to add it to the README I would really appreciate it