lf: by default, xdg-open shouldn't be called asynchronously

For example, I had my xdg-open configured to use a terminal audio player for audio files; this worked fine on ranger.

However, on lf with the default config, whem pressing l on a music file, the music would play, but I would still be navigating the folder. It took me a while to figure out that the default is to fork xdg-open, so the audio player’s command-line controls weren’t even accessible.

I ended up configuring cmd open $xdg-open "$f", which I think should be the default. It’s always possible for xdg-open to decide when or not to fork when opening certain files. For example, I’ve told mine to not fork when opening text and audio files, as those happen in the same terminal, but all others fork into a graphical window.

The other silly thing is that the fork cases worked normally, but essentially there were two forks taking place. A bit unnecessary 😃

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Well then this is exactly the dilemma faced by terminal file managers and no other programs face. xdg-open is meant for graphical programs and therefor in our case it (should) open any media files comfortably thanks to the command line options mpv.desktop has.

In comparison, running xdg-open file.txt opens file.txt in a new terminal / GUI editor’s new window - as you’d expect if you had used a graphical file manager. This is usually not desired when using a terminal file browser and that’s why you’d probably want to use e when hovering a text file you’d want to use the same terminal to edit / view it.

Ranger’s rifle kind of solves this dilemma specifically for terminal file mangers by essentially re-implementing most of xdg-open in Python and using a single configuration file. With rifle you can declare that for example:

  • text/* files will be openned by $EDITOR in the current terminal
  • application/media-whatever will be openned with mpv --player-operation-mode=pseudo-gui -- %U

Etc.

@mvdan I hope this helps. FWIW, I don’t think @gokcehan would want to implement rifle under the wings of this project.

You can use install ranger and only use rifle as your $OPENER.