pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
680 stars 162 forks source link

Open attachment with a custom command like xdg-open #1494

Open pacien opened 4 years ago

pacien commented 4 years ago

Is your feature request related to a problem? Please describe.

It'd be nice to let xdg-open decide which application should be used when opening some attachment in alot.

Currently, alot only tries to use the ~/.mailcap mapping, which has to be manually kept in sync with other MIME databases (mimeapps.list, desktop entries, …).

Describe the solution you'd like

An option could be added to delegate the application choice to another program, such as xdg-open.

Describe alternatives you've considered

It's not possible to add a global fallback in .mailcap such as */*; xdg-open "%s" because */* isn't a valid wildcard as per RFC1524 and isn't accepted by the Python lib.

Additional context

Since b1c93c4d0c1eeacd64a195f16861bcb73910e739, having text/*; xdg-open "%s" in .mailcap causes all text messages, not only attachments, to be opened externally. It's not possible to keep that entry to open log files attachments for instance.

pazz commented 4 years ago

Agreed. The (relatively simple) solution to add this feature would be to let alot.commands.thread.OpenAttachmentCommand accept a string parameter that will be used as handler_command.. PRs would be much appreciated.

pacien commented 4 years ago

I can add such command but currently opening attachments is done by the "select" command, which allows the use of the same keybinding to perform this action and others. Is it possible to bind the same key a new OpenAttachmentCommand?

pazz commented 4 years ago

Oh right, I overlooked that this command is not exposed to the alot ui directly. In fact, we could keep select as is and add another command open ? which would use OpenAttachmentCommand directly. Perhaps this can even be done by simply adding a new decorator around that class...

Quoting Notkea (2020-05-08 20:29:05)

I can add such command but currently opening attachments is done by the "select" command, which allows the use of the same keybinding to perform this action and others. Is it possible to bind the same key a new OpenAttachmentCommand?

— You are receiving this because you commented. Reply to this email directly, [1]view it on GitHub, or [2]unsubscribe.

References

Visible links

  1. https://github.com/pazz/alot/issues/1494#issuecomment-625979413
  2. https://github.com/notifications/unsubscribe-auth/AAEZNZ33MK554W5JCXQZPJDRQRMQDANCNFSM4MKHZOLQ
pacien commented 4 years ago

But it would be weird to have two commands doing the same thing in some cases. Maybe should that command argument be added to the "select" command, but it wouldn't make sense when the focused element is not an attachment.

pacien commented 4 years ago

Nevermind, it actually makes sense to have another command, similar to "pipeto". I'll prepare a patch for this.