GermainZ / xdg-desktop-portal-termfilechooser

xdg-desktop-portal backend for choosing files with your favorite file chooser
MIT License
71 stars 16 forks source link

File Dialogs not opening #1

Closed Dimfred closed 2 years ago

Dimfred commented 2 years ago

Hi great that you created this project! I am super happy (or at least will be when it works).

So I am kinda struggling to make everything work.

I verfied that the installed user service is indeed running: xdg-desktop-portal-termfilechooser.service I adapted the config file in ~/.config/xdg-desktop-portal-termfilechooser/config to:

[filechooser]
cmd=/home/dimfred/scripts/utils/rangerpicker
default_dir=downloads

My adapted command is also working and when running it directly from the shell everything is fine. However, when I try to open a filedialog (e.g. through thunderbird or telegram) nothing happens. For thunderbird I run GTK_USE_PORTAL=1 thunderbird, without the env var the default GTK dialog is used.

I also ran /usr/lib/xdg-desktop-portal-termfilechooser -l DEBUG -r, it seems to start normally, it finds the config and connects to dBus, where the service also shows up as org.freedesktop.impl.portal.desktop.termfilechooser.

I am on: 5.10.53-1-MANJARO; installed repo through AUR

Any suggestions?

Also I found it a bit irritating that the config did not install itself to ~/.config, which would be great to have in general, but this is another issue.

Cheers Dimfred

Dimfred commented 2 years ago

I did no restart after I fixed the config n stuff everything works now... LoL. Thank you very much, you made my life a lot better!

Carlisle96 commented 1 year ago

Can you explain how you got everything working ? I just build and installed but the service isn't even running

Dimfred commented 1 year ago

Hey, good question tbh I can't really remember. But I would first check whether the service file is there at all. If the service isn't activated activate it: sudo systemctl enable xdg-desktop-portal-termfilechooser sudo systemctl start xdg-desktop-portal-termfilechooser I think thats actually it and should get you going. Additionally some apps require the env var to start with the portal file picker: GTK_USE_PORTAL=1 <app name>

In the next days I'll probably will set it up again I can ping you my steps if those didn't help. Good luck

EDIT: now I remember the service file wasn't present at all. it is located here: https://github.com/GermainZ/xdg-desktop-portal-termfilechooser/blob/main/contrib/systemd/xdg-desktop-portal-termfilechooser.service.in I changed the @libexecdir@ to /usr/lib that should normally be the place where the bin is located. Additionally I specify the config in ExecStart: usr/lib/xdg-desktop-portal-termfilechooser -c /home/dimfred/xdg-desktop-portal-termfilechooser/config

So all in all I have this service:

  [Unit]                                                                                                 
  Description=Portal service (terminal file chooser implementation)                                      
  PartOf=graphical-session.target                                                                        
  After=graphical-session.target                                                                         

  [Service]                                                                                              
  Type=dbus                                                                                              
  BusName=org.freedesktop.impl.portal.desktop.termfilechooser                                            
  ExecStart=/usr/lib/xdg-desktop-portal-termfilechooser -c /home/dimfred/xdg-desktop-portal-termfilechoos
  er/config                                                                                              
  Restart=on-failure                                                                                     

  [Install]                                                                                              
  WantedBy=multi-user.target                                                                             

EDIT2: okayh I tried the stuff I showed you and it's not working for me. Also tried to start the service as a user service (--user) not sure whether it has to run as root, but it's sadly also not working. Will dig in the next days, cause I also want to have it running again.

Carlisle96 commented 1 year ago

I got everything up and running and can write a small little manual for you later today. systemctl does not actually work because it is a dbus-service - you can check running dbus services with qdbus.

I also found an error in the source code, which is the reason why multiline files don't work. If you are interested in all of it I am happy to provide everything later today.

GermainZ commented 1 year ago

A pull request would be greatly appreciated as well :)

On Tue, 23 Aug 2022, 10:55 Carlisle Nightingale, @.***> wrote:

I got everything up and running and can write a small little manual for you later today. systemctl does not actually work because it is a dbus-service - you can check running dbus services with qdbus.

I also found an error in the source code, which is the reason why multiline files don't work. If you are interested in all of it I am happy to provide everything later today.

— Reply to this email directly, view it on GitHub https://github.com/GermainZ/xdg-desktop-portal-termfilechooser/issues/1#issuecomment-1223838136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWFDFNZJV7R2TL4SGP5T6DV2SN2FANCNFSM5BIQSOSA . You are receiving this because you are subscribed to this thread.Message ID: <GermainZ/xdg-desktop-portal-termfilechooser/issues/1/1223838136@ github.com>

Dimfred commented 1 year ago

Oh that would be great! Thx mate

Dimfred commented 1 year ago

@Carlisle96 your writeup is still greatly appreciated :)

Carlisle96 commented 1 year ago

Alright,...

the thing is I do not have a final, good, complete solution for this. Due to this i was hesitant writing something, but here it goes:

You can use these two resources where I was trying to figure out what was going on: https://github.com/jarun/nnn/issues/1465 https://github.com/jarun/nnn/issues/1466

I will describe what worked for me (It might not be the only way to do it but it works for me) :

  1. Delete line 58 cr = getc(fp); in /src/filechooser/filechooser.c ( https://github.com/GermainZ/xdg-desktop-portal-termfilechooser/pull/2 would work, however moving it inside the if might create other issues )
  2. Build termfilechooser from source
  3. Need to have xdg-desktop-portal installed
  4. Put the files in these locations: /etc/systemd/system/xdg-desktop-portal-termfilechooser.service /usr/local/share/dbus-1/services/org.freedesktop.impl.portal.desktop.termfilechooser.service /usr/local/share/xdg-desktop-portal/portals/termfilechooser.portal /usr/local/lib/systemd/user/xdg-desktop-portal-termfilechooser.service /usr/share/xdg-desktop-portal/portals/termfilechooser.portal
  5. Update paths in those files to point to their counterparts
  6. export GTK_USE_PORTAL=1 and XDG_CURRENT_DESKTOP=i3 ( i3 needs to be in the list of the portal file ) for example in ~/.profile
  7. Make sure your file chooser program ( for example nnn ) is in /bin/ ( when I put it into ~/.local/bin/ and export it into my PATH it will not open it ( just a flickering window which closes immediately )
  8. Reboot and it should work ( Is neccecary to do, because dbus will load its parts on init. You can check which ones are active with qdbus ).

I am happy to talk with you about all steps to help or optimize it further.

There are still some bugs:

I would really like to solve these last issues to use this as my primary & only way to open files on my machine without the fear of it breaking. Would be happy to discuss / test / develop / implement this together if anyone is interested...

Grüße aus Berlin :p

Tokariew commented 1 year ago

@Carlisle96 thank you for the guide. I'm closer to running with default provided script… but i stuck with new error

2022/09/01 15:46:37 [DEBUG] - dbus: option multiple
2022/09/01 15:46:37 [DEBUG] - dbus: option multiple: 1
2022/09/01 15:46:37 [DEBUG] - dbus: option filters
2022/09/01 15:46:37 [WARN] - dbus: unknown option filters
[244 15:46:38.048860] [PARSE ERROR] Unknown char after ESC: 0x6b
[244 15:46:38.048874] [PARSE ERROR] Unknown char after ESC: 0x5c
[244 15:46:38.048880] [PARSE ERROR] Unknown char after ESC: 0x6b
[244 15:46:38.048885] [PARSE ERROR] Unknown char after ESC: 0x5c

The ranger window open for me, but only folders are visible, so can't select any file

edit: Being stupid and browser was ask for directory, when i chosen upload file… my bad. Work quite good, :)

Carlisle96 commented 1 year ago

I have to say. There are a lot of bugs happening for me... In general it feels very unstable.