flathub / org.freedownloadmanager.Manager

https://flathub.org/apps/details/org.freedownloadmanager.Manager
3 stars 3 forks source link

FDM couldn't recognize installed browsers #1

Open justraven opened 2 years ago

justraven commented 2 years ago

image

Hi, thanks for bringing FDM to flatpak!. The program runs smoothly on KDE Wayland ( I used deb before and it didn’t want to launch on wayland). Unfortunately, I notice that FDM on flatpak didn’t recognize my browser at all so it couldn’t integrate with my browser. I hope you can fix this issue. Thank you! [ sorry for my bad english, english isn’t my first language ].

Dansito commented 2 years ago

Hello, maybe this weekend I will try to make the integration work, hopefully it will work without major problems, I will communicate the progress through this issue.

Dansito commented 2 years ago

Hello again, could you install flatseal(in case you don't have it installed yet) and enable permission so that FDM can read the host? I think that way I could read the browsers(at least the native ones) it seems that there is no way to read the browsers installed with flatpak. A similar case happens with password manager programs and their integrations. @justraven

justraven commented 2 years ago

image

I've install flatseal and give the permission to the program but still can't read the browser

image

I have 2 browsers installed with native pkg (deb) : firefox and vivaldi

Dansito commented 2 years ago

It seems that the application obtains the information from the browsers in another way, this is complicated, considering that FDM is a proprietary application

Dansito commented 2 years ago

https://github.com/flathub/org.freedownloadmanager.Manager/blob/master/README.md

hopefully one day the situation will change.

justraven commented 2 years ago

I hope so

bayazidbh commented 2 years ago

Alright, I've been testing out the flatpak with natively installed browser. So far, I've managed to make it work with Firefox but not Brave (though I recall Brave having some weird config with its native host so I'll try it later with Edge and Chromium).

What I did is that I went to $HOME/.mozilla/native-messaging-hosts/ and edited the path in the org.freedownloadmanager.fdm5.cnh.json file to point to "\/var\/lib\/flatpak\/app\/org.freedownloadmanager.Manager\/current\/active\/files\/extra\/opt\/freedownloadmanager\/wenativehost".

At first, I saw that the extension DID detect the nativehost BUT when I tried to download something, it ONLY spawned an fdm tray icon but NOT the download manager window. However, after trying out the AppImage version I know that this is a Wayland issue and when I closed the tray icon, the handover process to the browser native downloader operated successfully as normally expected. Therefore, I tried it again with env WAYLAND_DISPLAY= firefox to force Firefox on x11, and the fdm window appeared.

Now, the caveats:

  1. Obviously, this isn't in any way intended or safe. I don't think it'll work with Flatpak'd browsers either, unless you go around poking sandbox holes on them which is, you know, caveat emptor.
  2. I'm not sure what kind of command is needed to ensure that the spawned fdm runs in x11, so that's a no-go on Wayland - considering that the main reason why anyone would want fdm on flatpak is probably because they're a Fedora user, that's a major showstopper (unless there's a way to always pass an env variable to a specific command/binary? Or maybe something we can pass through the qt.conf file?). Though if all you want is just faster downloads, you can probably just choose to always accept so that you don't need to deal with the GUI window.
  3. Notice the 'spawn' - it creates a separate instance of fdm with its own list and settings (most likely because we're bypassing sandbox) so you can't see your download list from the normal fdm, though you can still see it from the spawned fdm whenever you invoke it again from browser.

If we want to, we could probably add the command needed to automaticall rewrite the path on the README, provide files for both firefox and chromium for people to just overwrite the normal one with, or just write out the location of the file and what needed to be overwritten. But I don't think it's worth it, at least until fdm adopts Wayland- still, if anyone wants to pass this message to the main devs so that they can properly support flatpak, you can do so.

Honestly, I think it's better to just use the AppImage version, now that I know that the Brave issue has nothing to do with the AppImage version (which has the wenativehost in a hidden mounted fusefs in /tmp). I'll try to work out the Brave and Chromium files later, but it's such a headache - by all rights it should just pull in from $HOME/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts. Maybe it pulls from Chromium's xdg-config-home folder still?

justraven commented 2 years ago

image

I can confirm that it work on X11 using firefox (deb). Thanks @bayazidbh !

image

bayazidbh commented 2 years ago

A little bit of testing, it does seem like it works with Brave with its native host config file at $HOME/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/ by pointing it to \/var\/lib\/flatpak\/app\/org.freedownloadmanager.Manager\/current\/active\/files\/bin\/wenativehost. It's just that it seems the path sometimes gets reseted which is why I thought it doesn't work because I didn't double-check the file.

I recently saw some movement on the WebExtension support in xdg-desktop-portal so hopefully this will not be necessary anymore soon, although the x11 requirement will likely stay until FDM supports wayland.

tazihad commented 2 years ago

hey could you look into this script? This is done with keepassxc to work with browser addon. I think similar can be done with FDM. Ofcourse if you have free time.

Dansito commented 2 years ago

Forgive my inactivity a bit, I have been very busy in my personal life, if someone has the time and knowledge to make such a script, you can do a pr, I will take care of testing and verifying it, I am not that good with shell and right now I don't have the time to test :(

FanderWasTaken commented 1 year ago

I doubt it's possible to make this program work inside a sandbox when it comes to browser integration... Meanwhile I made a script to build an AppImage for it just so everyone could use that for now

bayazidbh commented 1 year ago

@FanderWasTaken This has been done in https://github.com/mi-g/vdhcoapp/issues/91#issuecomment-1247940392, however, I would recommend just waiting for NativeHostMessaging portal for a proper interface in Flatpak.

In the meanwhile, you can use Distrobox, Conty, and anything like them, and so long as both the browser and the app exists in the same container then they should work automatically.