如何通过命令行启动首选音频播放器?

agg*_*sol 4 command-line audio-player

我的 bash 脚本应该直接调用用户首选的音频播放器而不是 vlc 或 mplayer。我如何从 bash 调用它?我假设类似

audio-player --play music.mp3
Run Code Online (Sandbox Code Playgroud)

N0r*_*ert 11

尝试使用 XDG open,它应该使用默认应用程序打开文件:

xdg-open music.mp3
Run Code Online (Sandbox Code Playgroud)

xdg-open 手册页

姓名

   xdg-open - opens a file or URL in the user's preferred application
Run Code Online (Sandbox Code Playgroud)

概要

   xdg-open {file | URL}

   xdg-open {--help | --manual | --version}
Run Code Online (Sandbox Code Playgroud)

描述

   xdg-open opens a file or URL in the user's preferred application. If a
   URL is provided the URL will be opened in the user's preferred web
   browser. If a file is provided the file will be opened in the preferred
   application for files of that type. xdg-open supports file, ftp, http
   and https URLs.

   xdg-open is for use inside a desktop session only. It is not
   recommended to use xdg-open as root.
Run Code Online (Sandbox Code Playgroud)