De-hardcode mpg123
The MPEG player is no longer hard-coded as mpg123, and now customizable by changing the enum `DEFAULT_MPEGPLAYER`.
This commit is contained in:
parent
04aea47d80
commit
4992a8684c
1 changed files with 14 additions and 3 deletions
17
main.d
17
main.d
|
@ -33,6 +33,7 @@ import dini;
|
|||
enum VERSION = "0.1.0";
|
||||
|
||||
enum DEFAULT_CONFIGPATH = "~/.config/esv.conf";
|
||||
enum DEFAULT_MPEGPLAYER = "mpg123";
|
||||
enum DEFAULT_PAGER = "less";
|
||||
|
||||
enum ENV_CONFIG = "ESV_CONFIG";
|
||||
|
@ -170,13 +171,23 @@ int main(string[] args)
|
|||
|
||||
if (optAudio) {
|
||||
// check for mpg123
|
||||
if (executeShell("which mpg123 >/dev/null 2>&1").status > 0) {
|
||||
panic("mpg123 is required for audio mode; cannot continue");
|
||||
if (executeShell("which " ~ DEFAULT_MPEGPLAYER ~ " >/dev/null 2>&1").status > 0) {
|
||||
panic(DEFAULT_MPEGPLAYER ~ " is required for audio mode; cannot continue");
|
||||
return 1;
|
||||
} else {
|
||||
string tmpf = esv.getAudioVerses(args[1], args[2]);
|
||||
string mpegPlayer;
|
||||
// esv has built-in support for mpg123 and mpv
|
||||
// other players will work, just recompile with
|
||||
// the DEFAULT_MPEGPLAYER enum set differently
|
||||
if (DEFAULT_MPEGPLAYER == "mpg123")
|
||||
mpegPlayer = DEFAULT_MPEGPLAYER ~ " -q ";
|
||||
else if (DEFAULT_MPEGPLAYER == "mpv")
|
||||
mpegPlayer = DEFAULT_MPEGPLAYER ~ " --msg-level=all=no ";
|
||||
else
|
||||
mpegPlayer = DEFAULT_MPEGPLAYER ~ " ";
|
||||
// spawn mpg123
|
||||
executeShell("mpg123 -q " ~ tmpf);
|
||||
executeShell(mpegPlayer ~ tmpf);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue