How to properly and easily configure `xdg-open` without any environment?

I'm making use of OpenBox window supervisor with no desktop computer setting .

xdg-open acts oddly. It opens up every little thing with firefox.

$ xdg-settings --list
Known properties:
  default-web-browser           Default web browser

I'm seeking a straightforward program ; something like reviewing every *.desktop documents in /usr/share/applications/ folder and also instantly establishing xdg setups.

110
2022-06-06 23:38:43
Source Share
Answers: 4

You could use something like this to generate the appropriate xdg-mime commands for each of your .desktop files and the mimetypes they contain, then execute the ones you like. Note /usr/share/applications might have subdirectories.

find /usr/share/applications ~/.local/share/applications -iname '*.desktop' -print0 | while IFS= read -r -d $'\0' d; do
  for m in $(grep MimeType "$d" | cut -d= -f2 | tr ";" " "); do
    echo xdg-mime default "'$d'" "'$m'"
  done
done
11
2022-07-11 04:21:16
Source

Why not to make use of energies from xdg itself?

To make Thunar the default documents - internet browser, i.e. the default application for opening up folders.

$ xdg-mime default Thunar.desktop inode/directory

to make use of xpdf as the default PDF viewer:

$ xdg-mime default xpdf.desktop application/pdf

This need to create an access

[Default Applications]
application/pdf=xpdf.desktop

in your neighborhood MIME data source ~/.config/mimeapps.list.

Your PDF files need to be opened up with xpdf currently.

128
2022-07-07 01:32:56
Source

On Debian you can make use of the command, as origin

update-mime-database /usr/share/mime

having the shared-mime-info plan mounted.

11
2022-06-06 23:58:27
Source

You can install and also make use of perl-file-mimeinfo in the extra database to take care of mimetypes.

Instance to open all .pdf files in apvlv:

/usr/bin/vendor_perl/mimeopen -d $file.pdf

or on various other Linux circulations where mimeopen is NOT in /usr/bin/vendor_perl/ yet remains in among the $PATH directory sites:

mimeopen -d $file.pdf

and afterwards, at the punctual, enter the application: apvlv.

37
2022-06-06 23:54:21
Source