Bash: getting a standard program for a file type

background is a shell script to open a web radio station .m3u file. Therefore, I want to know inside the script that the user program opens such files. At the moment, it should set the $ PLAYER environment variable, but obviously this is not a good way.

Alternative: is there a command that takes a file name and looks for itself for the appropriate program to process this file? For example file, for example,

open-file my_playlist.m3u

The script should be portable, it will work, at least on Ubuntu, Debian and Windows / Cygwin machines.

Greetings

+3
source share
2 answers

- . Mac OS X "open" , .

Linux , (GNOME KDE) .

Ubuntu/GNOME , : ~/.local/share/applications/defaults.list ~/.local///mimeinfo.cache

-, , , Windows .

: :

Linux:

xdg-open [_]

Cygwin:

cygstart [_]

, , , : bash Script

+8

, , , (, nautilus, konqueror, thunar, mc... ​​ AFAIK), , ...

- , .

0

Source: https://habr.com/ru/post/1711270/


All Articles