chmln / handlr

A better xdg-utils
MIT License
607 stars 24 forks source link

Use handlr for D-Bus's FileManager1 #36

Open ghost opened 3 years ago

ghost commented 3 years ago

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?

chmln commented 3 years ago

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?

ghost commented 3 years ago

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 commented 3 years ago

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:

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

zoqaeski commented 3 years ago

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.