added pw-cat for pipewire playback
[feisty_meow.git] / scripts / multimedia / sound_play.sh
1 #!/bin/bash
2
3 # play the sound files specified.
4
5 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
6
7 if [ $# -lt 1 ]; then
8   #echo no sound file specified.
9   exit 0;
10 fi
11
12 export BASIC_PLAY_CMD='echo Unknown basic sound player...'
13
14 if [ -f "/usr/bin/play" ]; then
15 #echo we see /usr/bin/play available...
16   BASIC_PLAY_CMD=/usr/bin/play
17 elif [ ! -z "$WINDIR" ]; then
18 #echo "kludge for win32; we provide our own sound player."
19   BASIC_PLAY_CMD=playsound
20 elif [ ! -z "$(whichable afplay)" ]; then
21 #echo we see afplay available...
22   BASIC_PLAY_CMD=afplay
23 elif [ ! -z "$(psfind artsd)" ]; then
24 #echo we see artsd running...
25   BASIC_PLAY_CMD=artsplay
26 elif [ ! -z "$(psfind esd)" ]; then
27 #echo  we see esd running...
28   BASIC_PLAY_CMD=esdplay
29 elif [ ! -z "$(psfind pulseaudio)" ]; then
30 #echo we see pulse running...
31   BASIC_PLAY_CMD="padsp aplay"
32 elif [ ! -z "$(whichable pw-cat)" ]; then
33   BASIC_PLAY_CMD="pw-cat -p"
34 else
35   echo "I don't know how to play basic sound files for this OS and sound system."
36 fi
37
38 export MP3_PLAY_CMD='echo Unknown mp3 player...'
39
40 if [ ! -z "$(whichable mplayer)" ]; then
41   MP3_PLAY_CMD=mplayer
42 else
43   echo "I don't know how to play mp3 files for this OS and sound system."
44 fi
45
46 # play the sounds individually; some apps like playsound can handle multiple
47 # files, but "/usr/bin/play" doesn't want to on some systems.
48 for filename in $*; do 
49   case "$filename" in
50     *wav)
51     $BASIC_PLAY_CMD $filename >/dev/null 2>&1;
52     ;;
53     *mp3)
54     $MP3_PLAY_CMD $filename >/dev/null 2>&1;
55     ;;
56     *)
57     echo "I don't know the file extension here: $filename"
58     ;;
59   esac
60 done
61
62 exit 0
63