Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make file: URLs work in command line so that %u in the desktop file works as advertised #121

Closed
ghost opened this issue Feb 12, 2023 · 26 comments

Comments

@ghost
Copy link

ghost commented Feb 12, 2023

In /usr/share/applications/betterbird.desktop, the Exec directive says:

Exec=betterbird %u

The "XDG Desktop Entry Specification" states that "%u" is "A single URL. Local files may either be passed as file: URLs or as file path. ".

However, Betterbird does not seem to support "file: URLs" paths.

In fact, I use mimeo as my file opener.

When I configure it to open .ics files with Betterbird, it calls:

❯ mimeo --debug [MYFILE].ics 
[...]
DEBUG: betterbird file:///home/[MYUSERNAME]/Downloads/[MYFILE].ics

and Betterbird stalls and doesn't start.

So I think the "%u" in the desktop file should be "%f", which is described by the specification as "A single file name (including the path)", which is what Betterbird seems to support.

Upstream bug.

@Betterbird
Copy link
Owner

Betterbird commented Feb 12, 2023

Hmm, well, the substitution of %u with file:///home/[MYUSERNAME]/Downloads/[MYFILE].ics was done correctly and the file: URL is also correct. The issue if that TB/BB apparently cannot open an ICS file when invoked with the file as argument.

What happens if you chance the .desktop file to Exec=betterbird %f - Does that work any better? What is the invocation argument then? betterbird /home/[MYUSERNAME]/Downloads/[MYFILE].ics? That would equally not work, or does it? We're happy to make a one character change, but only if it improves the situation.

On second thought, shouldn't it be Exec=betterbird -url %u? At least this works:
betterbird -url mailto:[email protected]. We tried this on Windows: betterbird -url file:///some/path/ff.ics and that starts BB just to close it instantly. So something goes wrong with opening the ICS file.

Apparently there is a -file argument, see https://support.mozilla.org/en-US/kb/new-thunderbird-78#w_calendar-import-ics-files-via-file-command-line-option. And lo and behold, betterbird.exe -file D:\Desktop\ff.ics -p default works on Windows.

So it should be Exec=betterbird -file %f, right? Can you try this?

@Betterbird
Copy link
Owner

@mfschumann - do you have an opinion here? Did %u ever do something useful?

@mfschumann
Copy link
Contributor

@mfschumann - do you have an opinion here? Did %u ever do something useful?

%u is currently in there because that's what they do for the Thunderbird flatpak. Before changing anything we should probably make sure we don't introduce a regression. Thinking of the issue about LibreOffice integration I wouldn't be surprised if there were file types that need their path converted to a URL and others that don't. But that's pure speculation.

So I guess my question is: What file types is Betterbird supposed to open apart from ICS? Do they all work with %f instead of %u?

@ghost
Copy link
Author

ghost commented Feb 13, 2023

What happens if you chance the .desktop file to Exec=betterbird %f - Does that work any better?

Yes it works

What is the invocation argument then? betterbird /home/[MYUSERNAME]/Downloads/[MYFILE].ics?

Yes


❯ cat /usr/share/applications/betterbird.desktop | grep Exec | head -1
Exec=betterbird %f

❯ mimeo --debug ./Downloads/[MYFILE].ics 
DEBUG: parsing /usr/share/applications/betterbird.desktop
DEBUG: betterbird ./Downloads/[MYFILE].ics

That would equally not work, or does it?

Yes, betterbird /path/to/file.ics works.

Apparently there is a -file argument, see https://support.mozilla.org/en-US/kb/new-thunderbird-78#w_calendar-import-ics-files-via-file-command-line-option. And lo and behold, betterbird.exe -file D:\Desktop\ff.ics -p default works on Windows.
So it should be Exec=betterbird -file %f, right? Can you try this?

Both betterbird MYFILE.ics and betterbird -file MYFILE.ics works.

@Betterbird
Copy link
Owner

In reply to @mfschumann: Do LO use the .dektop file? They just have their own more or less hard-coded invocation with -remote or -compose. Or do they replace the %u?

I guess you can also lauch with .eml files, like so on WIndows:

betterbird.exe d:\desktop\test-mailquote-enter.eml
betterbird.exe -file d:\desktop\test-mailquote-enter.eml

This betterbird.exe -url file:///d:/desktop/test-mailquote-enter.eml doesn't appear to work.

The ICS handling code is here:
https://searchfox.org/comm-central/rev/20d1d1732df9821760f002fdf941f0c6c2de24dc/mail/components/MessengerContentHandler.jsm#515
One would need to carefully read what the entire function does.

That said, one would also need to see was Linux does with the .desktop file and under which circumstances the Exec directive is used.

In reply to @875d: On Windows betterbird.exe d:\desktop\ff.ics also works.

@ghost
Copy link
Author

ghost commented Feb 13, 2023

That said, one would also need to see was Linux does with the .desktop file and under which circumstances the Exec directive is used.

It should be used by every software that abides by the XDG Desktop Entry Specification.

I use a tiling window manager with mimeo as file opener.

It would be worthwhile to see how GNOME or KDE substitute the %u, provided the specification says it can be substituted with file: URL legitimately.

@Betterbird
Copy link
Owner

Well, if BB is already running and I do betterbird.exe file:///d:/desktop/ff.ics I get this:
image

So maybe that should just be made to work, right?

@ghost
Copy link
Author

ghost commented Feb 13, 2023

It looks like it removed the ///. It could certainly be made to work, but it is easier to just substitute %u with %f

@Betterbird
Copy link
Owner

Well, it messed up the file: URL completely. Yes, it would be easier to change to %f, but as you rightly pointed out, the "contract" is that you can pass a (file:) URL and it should "just work"(TM). Anyway, not a terribly urgent problem since you can just change the .desktop file.

@ghost
Copy link
Author

ghost commented Feb 13, 2023

Well, it messed up the file: URL completely. Yes, it would be easier to change to %f, but as you rightly pointed out, the "contract" is that you can pass a (file:) URL and it should "just work"(TM). Anyway, not a terribly urgent problem since you can just change the .desktop file.

Well we can have a new contract with the %f option.

Yes it is not urgent at all. But the .desktop file will be overwritten when you update the software or you reinstall it (e.g. if you have to format).

If time passes between update / reinstalling, you can forget what was the problem.

Anyway I love how you take it "more seriously" and just doesn't discard it as "never matter" :)

@Betterbird
Copy link
Owner

%f and -file %f already works, no "new contract" needed. Personally, I find the entire matter annoying, I mean, that you need try and error to see what works.

@ghost
Copy link
Author

ghost commented Feb 13, 2023

%f and -file %f already works, no "new contract" needed. Personally, I find the entire matter annoying, I mean, that you need try and error to see what works.

File path works, file URL: does not work.

You need to try because there is a bug: TB/BB claim to support something which they don't support (i.e. file URL:).

It they claimed to support only file path there wouldn't be no problem.

@Betterbird
Copy link
Owner

Should be fixed in 167afd4
https://github.com/Betterbird/thunderbird-patches/blob/main/102/bugs/1816343-command-line-file-url.patch
Will ship in BB 102.8.0-bb30 tomorrow.

Please do me a favour: Adjust the upstream bug accordingly and paste the link to the patch.

The upstream bug is invalid as it stands since TB do not provide the desktop file. The bug really is that file: URLs don't work.

@Betterbird Betterbird changed the title Desktop file should contain %f instead of %u Make file: URLs work in command line so that %u in the desktop file works as advertised Feb 13, 2023
@ghost
Copy link
Author

ghost commented Feb 13, 2023

The upstream bug is invalid as it stands since TB do not provide the desktop file. The bug really is that file: URLs don't work.

So who provides the desktop file?

I installed Thunderbird from Arch official repo.

There was a desktop file in it.

Who provided it?

@mfschumann
Copy link
Contributor

In reply to @mfschumann: Do LO use the .dektop file? They just have their own more or less hard-coded invocation with -remote or -compose. Or do they replace the %u?

AFAIK they don't use the .desktop file.

To my understanding the .desktop file is used when Betterbird is set as default file handler for some file type and a file of that type is double clicked or dragged onto the Betterbird icon.

If .eml and .ics files are the only items where it makes sense to set Betterbird as default file handler, it should be safe to change %u to %f. If there is any url-like thing that Betterbird can act as default file handler for, it would be better to fix the code that currently errors when trying to load files given as file:// urls.

@Betterbird
Copy link
Owner

Betterbird commented Feb 13, 2023

Who provided it?

Arch/AUR do.

P.S.: @875d - please adjust the upstream bug.

@ghost
Copy link
Author

ghost commented Feb 13, 2023

If there is any url-like thing that Betterbird can act as default file handler for, it would be better to fix the code that currently errors when trying to load files given as file:// urls.

Oh, I see. Something like magnet link?

The Mimetype in the desktop file says:

MimeType=message/rfc822;x-scheme-handler/mailto;application/x-xpinstall;

so application/x-extension-ics is missing

Arch/AUR do.

Ok, so I have to put up with the Arch maintainer

@Betterbird
Copy link
Owner

Ok, so I have to put up with the Arch maintainer

Well, they mostly copy our .desktop file here:
https://github.com/Betterbird/thunderbird-patches/blob/main/metadata/eu.betterbird.Betterbird.desktop

I can add that and let the AUR maintainer know.

@ghost
Copy link
Author

ghost commented Feb 13, 2023

P.S.: @875d - please adjust the upstream bug.

I updated the upstream bug to point to the patch and this issue.

Thanks.

@ghost
Copy link
Author

ghost commented Feb 13, 2023

Ok, so I have to put up with the Arch maintainer

Well, they mostly copy our .desktop file here: https://github.com/Betterbird/thunderbird-patches/blob/main/metadata/eu.betterbird.Betterbird.desktop

I can add that and let the AUR maintainer know.

Yes, please add the mimetype for ics file. Thanks.

@Betterbird
Copy link
Owner

Done. @Posi81: Please note the change to the .desktop file and adjust accordingly in AUR.

@Betterbird
Copy link
Owner

I updated the upstream bug to point to the patch and this issue.

Thanks. You could consider doing "Edit Bug" and changing the summary/title since they don't ship any desktop files. Something like:
Command handler doesn't handle file:// URLs leading to problems opening .ics or .eml files via the XDG Desktop Entry Specification using %u
(or words to that extent).

@ghost
Copy link
Author

ghost commented Feb 13, 2023

Done. @Posi81: Please note the change to the .desktop file and adjust accordingly in AUR.

Oh we have the AUR package maintainer here?

@ghost
Copy link
Author

ghost commented Feb 13, 2023

I updated the upstream bug to point to the patch and this issue.

Thanks. You could consider doing "Edit Bug" and changing the summary/title since they don't ship any desktop files. Something like: Command handler doesn't handle file:// URLs leading to problems opening .ics or .eml files via the XDG Desktop Entry Specification using %u (or words to that extent).

Done. Thanks.

@Betterbird
Copy link
Owner

Oh we have the AUR package maintainer here?

Yes, we do, but I talk to him privately about new releases. All in good hands.

@Posi81
Copy link

Posi81 commented Feb 13, 2023

Hi there :-)
I will adjust the .desktop file accordingly in AUR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants