You are not logged in.

#1 2022-12-31 01:21:59

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

[SOLVED] How does Firefox know how to open the file manager

Hi there,

Whenever I click the downloaded file in Firefox, it opens the file manager (Dolphin in my case) with the file already selected. The command line being run by Fireofx is:

/usr/bin/dolphin --new-window --select /zork/Downloads/labels_63af6eb953c4b.pdf

Where does Firefox get that command line from?

Thanks in advance.

Last edited by mdcclxv (2023-01-03 23:20:18)

Offline

#2 2022-12-31 07:55:22

8472
Member
From: Slovakia
Registered: 2010-05-15
Posts: 89

Re: [SOLVED] How does Firefox know how to open the file manager

Not sure if this one https://bugzilla.mozilla.org/show_bug.cgi?id=1285711 answer your question, but it's also an view of how chaotic are some things in there.


Logic clearly dictates that the needs of the many outweigh the needs of the few.

Offline

#3 2022-12-31 13:13:33

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] How does Firefox know how to open the file manager

In my system FF obeys the inode/directory setting in ~/.config/mimeapps.list — is that not the case for you?

https://wiki.archlinux.org/title/XDG_MIME_Applications


Jin, Jîyan, Azadî

Offline

#4 2022-12-31 15:51:18

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

Ok, so my problem is not really about the default file manager, as I only have Dolphin, no other. The thing is that my /usr/share/applications/org.kde.dolphin.desktop is modified so that Dolphin will launch with a qss file that customizes its look:

Exec=dolphin %u -stylesheet /zork/WinExt/Dolphin/folder-background.qss

Output of xdg-mime:

xdg-mime query default inode/directory
org.kde.dolphin.desktop

I guess you can now spot my problem: Firefox does not use that desktop file, so Dolphin will run without using my qss. Hence my need to customize as well the way Firefox will launch Dolphin.

Last edited by mdcclxv (2022-12-31 15:51:55)

Offline

#5 2022-12-31 16:16:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] How does Firefox know how to open the file manager

mdcclxv wrote:

Firefox does not use that desktop file

Your results might suggest that, but the diagnostic commands you posted show the opposite: the xdg settings do direct to a desktop file with that name.  However, these files can be in multiple places and some locations take precedence over the /usr/share directory (and you should not edit the content in /usr/share directly anyways).  What is the output of the following:

find /usr/share /etc $HOME -name org.kde.dolphin.desktop

Last edited by Trilby (2022-12-31 16:20:55)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2022-12-31 18:06:44

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

That's my point, Firefox is successfully ignoring what's configured for inode/directory, using instead whatever is using.

Here is the output:

/zork: sudo find /usr/share /etc $HOME -name org.kde.dolphin.desktop
/usr/share/applications/org.kde.dolphin.desktop
/usr/share/kglobalaccel/org.kde.dolphin.desktop

Same output without sudo.

The second item is actually a symbolic link to the first item.

Last edited by mdcclxv (2022-12-31 18:10:06)

Offline

#7 2022-12-31 20:17:56

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] How does Firefox know how to open the file manager

Just use a wrapper script to call dolphin with your options. No need to play around with .desktop files then.


Jin, Jîyan, Azadî

Offline

#8 2022-12-31 20:26:52

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

That was the first thing I tried, Firefox is launching Dolphin with full path, that is, /usr/bin/dolphin.

Offline

#9 2022-12-31 20:39:47

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

Ok, so that command line must be configurable somewhere, I just installed Edge and is behaving exactly the same as Firefox. It's just that I have no idea where.

Offline

#10 2022-12-31 20:40:44

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] How does Firefox know how to open the file manager

How do you know FF is calling the full path?

Where did you place the wrapper? Is the directory searched ahead of /usr/bin/ in PATH?


Jin, Jîyan, Azadî

Offline

#11 2022-12-31 20:46:08

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

Head_on_a_Stick wrote:

How do you know FF is calling the full path?

Where did you place the wrapper? Is the directory searched ahead of /usr/bin/ in PATH?

It's definitely not calling my "dolphin" bash script from ~/bin, which is the first directory in the PATH. My script has no .sh extension, just the usual shebang. Tried with the .sh extension too, same thing.

Last edited by mdcclxv (2022-12-31 20:47:09)

Offline

#12 2022-12-31 22:10:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,418

Re: [SOLVED] How does Firefox know how to open the file manager

Tried

Exec=dolphin -stylesheet /zork/WinExt/Dolphin/folder-background.qss %u

?
I'd not be surprised if anything after the url is dropped.

Offline

#13 2022-12-31 23:55:09

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

seth wrote:

Tried

Exec=dolphin -stylesheet /zork/WinExt/Dolphin/folder-background.qss %u

?
I'd not be surprised if anything after the url is dropped.

Not sure what you mean by "url" sad  Exactly which part of that line do you think is getting dropped?

Offline

#14 2023-01-01 00:08:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,418

Re: [SOLVED] How does Firefox know how to open the file manager

What do you think "%u" encodes?
And the part after it might be cut off by FF.

Offline

#15 2023-01-01 00:13:46

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

While I did not read about inner workings of .desktop files, this %u looks very similar to how Windows is doing it. So, IMO, the"%u" part will be replaced with whatever parameters an app will send when launching the .desktop file. There is no part after the %u, it IS the last part.

Offline

#16 2023-01-01 00:25:06

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,418

Re: [SOLVED] How does Firefox know how to open the file manager

FF is clearly not sending anything there, the "--new-window --select" has to come from somewhere.
And "%u" is NOT the last segment in your replacement Exec line, that's the whole point I'm trying to make…

Offline

#17 2023-01-01 10:31:01

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

Ok, so we're back to square one. Where is it coming from? That would shed light on the whole shenanigans.

Offline

#18 2023-01-01 10:57:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,418

Re: [SOLVED] How does Firefox know how to open the file manager

No, we're not.

It's coming from FF. Since there's no gloal API to do what it wants to do, it has to build the command.
Its reasonable input is the mime database.
A plausible approach would be to parse that, detect known FMs and apply relevant parameters.
A plausible approach to that would be to substitute s/%[uUfF].*/ and in that case, your styleshit parameter gets lost.

And somehow yuo refuse to use a somewhat canonical commandline to een test that theory.
We're not back to square one, you're napping there.

Also, depending on how you start the sessuion: if you prepend $HOME/bin to your $PATH in your bashrc, that will not extend to your gui shell or firefox.

Offline

#19 2023-01-01 16:27:58

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

And somehow yuo refuse to use a somewhat canonical commandline to een test that theory.
We're not back to square one, you're napping there.

Not napping, not refusing anything. What exactly am I supposed to do? You completely lost me here.

Also, depending on how you start the sessuion: if you prepend $HOME/bin to your $PATH in your bashrc, that will not extend to your gui shell or firefox.

That's how I'm doing it, I'm not aware of any other way.
EDIT: I got it now, .bashrc is only used by bash when it starts. I did not make this connection up until now.

Last edited by mdcclxv (2023-01-01 16:34:00)

Offline

#20 2023-01-01 16:37:37

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,418

Re: [SOLVED] How does Firefox know how to open the file manager

What exactly am I supposed to do?

1. switch the commandline order to have the %u tail the command, https://bbs.archlinux.org/viewtopic.php … 8#p2076878
2. try to break the service and see how FF responds to that

Exec=shark -stylesheet /zork/WinExt/Dolphin/folder-background.qss %u

I'm not aware of any other way.

/etc/profile.d

Offline

#21 2023-01-01 17:40:50

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

seth wrote:

1. switch the commandline order to have the %u tail the command, https://bbs.archlinux.org/viewtopic.php … 8#p2076878

My bad here, I was convinced I already did that, except I actually didn't sad That's why I was at a loss with the canonical cmd line.


seth wrote:

2. try to break the service and see how FF responds to that

Exec=shark -stylesheet /zork/WinExt/Dolphin/folder-background.qss %u

Went straight for no 2, FF is still executing Dolphin. I tried the same thing for the mime entry inode/directory, with the same outcome: FF still executes Dolphin.


seth wrote:

/etc/profile.d

Did some reading, went for $HOME/.config/plasma-workspace/env/ way.

So now my "dolphin" wrapper script does get executed when invoking dolphin via Alt+Space (KDE with Plasma 5.5 here), but from FF all I get is the mouse cursor jumping for a couple of seconds, nothing else, and htop doesn't show a "dolphin" being executed. I've launched FF from a bash prompt, no related message there from FF. If I rename my wrapper script to something else, FF successfully launches Dolphin.

What  am I missing?

Offline

#22 2023-01-01 17:51:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] How does Firefox know how to open the file manager

If I read your last post correctly, that's a very useful "failure".  When your wrapper script is in place, firefox does somthing different than when it's not, correct?  If so, the wrapper script must get run.  What is in the wrapper script exactly?  Can you log a timestamp to a file to confirm it is running from firefox?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#23 2023-01-01 18:14:20

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

This is the script:

#!/bin/bash
echo "$@" > /zork/params.txt
kcalc &
/usr/bin/dolphin -stylesheet /zork/WinExt/Dolphin/folder-background.qss "$@" &

The params.txt file gets created when I try launching dolphin from FF and contains the expected string, that is, "--new-window --select /zork/Downloads/labels_63af6eb953c4b.pdf". But that's all there is to it. No kcalc, no dolphin.

Offline

#24 2023-01-01 19:25:40

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] How does Firefox know how to open the file manager

Why are you forking dolphin? Remove the ampersand at the end of the last line. And why is kcalc also called? That's just weird. Try it without that line.

I would ask why you're using a bash shebang in a script that doesn't use bashisms but I suppose you won't have upgraded /bin/sh to point to dash so that doesn't really matter.


Jin, Jîyan, Azadî

Offline

#25 2023-01-01 22:13:29

mdcclxv
Member
Registered: 2022-04-26
Posts: 207

Re: [SOLVED] How does Firefox know how to open the file manager

Head_on_a_Stick wrote:

Why are you forking dolphin? Remove the ampersand at the end of the last line. And why is kcalc also called? That's just weird. Try it without that line.

The forking was added in desperation, initially I had the script without it, having the same result. Fork or no fork, dolphin is not running via the script.
I added kcalc just to make sure that I'm not hitting some issue that Dolphin might have had in this particular scenario, so I needed something else to see running. Which is not happening.


Head_on_a_Stick wrote:

I would ask why you're using a bash shebang in a script that doesn't use bashisms but I suppose you won't have upgraded /bin/sh to point to dash so that doesn't really matter.

You lost me here. How is the script supposed to be recognized as a bash script without having a shebang?

Offline

Board footer

Powered by FluxBB