handlr icon indicating copy to clipboard operation
handlr copied to clipboard

Use handlr for D-Bus's FileManager1

Open ghost opened this issue 4 years ago • 4 comments

According to https://wiki.archlinux.org/index.php/default_applications , firefox and other applications does not use xdg-open, but dbus. For those apps, I mostly care about opening in a file manager. For example, for Firefox: opening a download in ranger rather than in nautilus. Well.. I decided to try using handlr even here.

Following https://wiki.archlinux.org/index.php/File_manager_functionality#D-Bus , I created the following file: ~/.local/share/dbus-1/services/filemanager.FileManager1.service with inside:

[D-BUS Service]
Name=org.freedesktop.FileManager1
Exec=/usr/bin/handlr open

This works as expected if xterm is installed, but not otherwise. For example, opening firefox from terminal to log errors I get:

% firefox
sh: line 1: exec: xterm: not found

handlr should be set.. I have in ~/.config/mimeapps.list:

[Default Applications]
x-scheme-handler/terminal=Alacritty.desktop;
inode/directory=ranger.desktop;

and in ~/.local/share/applications/ranger.desktop:

[Desktop Entry]
Name=ranger
Type=Application
Terminal=true
Exec=ranger %f
Categories=System;FileManager
MimeType=inode/directory;

Using handlr open $HOME works as expected. What should I try?

ghost avatar Apr 24 '21 22:04 ghost

Well.. I decided to try using handlr even here.

That's the spirit. Can you check if setting another terminal as x-scheme-handler/terminal makes it work?

chmln avatar Apr 25 '21 04:04 chmln

I tried with kitty.desktop and urxvt.desktop.. they also don't work. Though, from the README, the priority seems to be on a terminal with TerminalEmulator category. So I don't really understand why it doesn't pick the first one it finds. Anyway, I think it would be best to check first for x-scheme-handler/terminal, since it makes it possible to choose between different terminals with dmenu, instead of picking the first .desktop that match the category

ghost avatar Apr 25 '21 09:04 ghost

Still nothing with alacritty and version 0.6.4.. However.. I tried it works with gnome-terminal! I don't know where, but this means it is hardcoded in D-Bus

Since by "it works" I mean ranger is opened, I guess the following is happening:

  • D-Bus run's handlr open due to ~/.local/share/dbus-1/services/filemanager.FileManager1.service
  • handlr tells D-Bus to use the ranger.desktop as file manager
  • D-Bus opens it with and hardcoded terminal

Don't know where to look though. Using grep on / I cannot find any occurrence of xterm in any of my system files

ghost avatar May 02 '21 08:05 ghost

The issue is due to GLib having hardcoded terminal applications, and xterm is the fallback when everything else fails. See this ten year old bug report for more information: https://gitlab.gnome.org/GNOME/glib/-/issues/338

In order to set your terminal to something else, you may want to symlink it to xterm.

zoqaeski avatar Jun 17 '21 07:06 zoqaeski