3 ms·
> xdg-open, which as it turns out opens text files in Firefox, even though light weight editors are present on the system. It opens text files in Emacs here –
by claudius 11y ago
> xdg-open, which as it turns out opens text files in Firefox, even though light weight editors are present on the system.
It opens text files in Emacs here – did you configure your system to associate the text/plain mimetype to Firefox? (The following mostly for anybody who is interested):
$ xdg-mime query filetype <file>
will print the mimetype of <file>.
$ xdg-mime query default <mimetype>
will print the default .desktop file associated to this mimetype, i.e. the application that is run if you do xdg-open. That application can be changed using
$ xdg-mime default <.desktop> <mimetype> [<mimetype>*]
Maybe that particular distribution was misconfigured to have the default for text files be Firefox, but overall I don’t find the behaviour particularly surprising.
- matart 11y agoFrom what I understand from the parent post is that xdg-open on any given system does not seem to work in a repeatable way.
- tinco 11y agoI've never encountered a system where xdg-open did something I didn't expect. It's basically the linux variant of windows' double-click and OSX's open. If I did it on a text file and it would open it in Firefox I would think "Jeez what idiot chose Firefox for text files" not "Jeez xdg-open is useless".
- listic 11y agoI thought `xdg-open` is the Linux' variant of Windows' `start`.
- claudius 11y agoIt opens the file. In which particular way it opens that file of course depends on the system in question – I don’t have Emacs on my phone, I don’t want xdg-open to attempt to open text files with Emacs on my phone. Whether or not the apparent distribution default of opening text files with Firefox makes sense is an issue somewhat orthogonal to whether xdg-open works – in that particular case it may have been misconfigured to open files with Firefox, but that doesn’t mean it a) didn’t open the file (it did) nor b) in a completely unreasonable way (the file was still displayed and such).
- creshal 11y agoxdg-open chainloads a desktop-environment specific loader if available, and only if not, uses a heuristic to determine what program to load. Currently it supports three different loaders for various KDE versions, two Gnome loaders (one of which is shared with Mate, which also has its own loader supported), and one for each Xfce, LXDE and Enlightenment. If none of those are found, xdg-mime will be used. Relying on xdg-open to work sanely across desktops, much less across distributions, is… optimistic at best.