Update soundtest
[grml-scripts.git] / usr_bin / soundtest
1 #!/bin/sh
2 # Filename:      soundtest
3 # Purpose:       test sound on your grml system
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Sam Jän 19 17:08:34 CET 2008 [mika]
8 ################################################################################
9
10 PN=`basename "$0"`
11
12 if [ -z "$PLAYER" ] ; then
13    [ -x /usr/bin/mplayer ] && PLAYER="mplayer"
14    [ -x /usr/bin/ogg123 ]  && PLAYER="ogg123"
15 fi
16
17 if ! [ $(which $PLAYER) ] ; then
18    echo "Sorry, neither mplayer nor ogg123 available and \$PLAYER is not set.">&2
19    exit 1
20 fi
21
22 if [ -z "$1" ] ; then
23    FILE="/usr/share/grml/effect.ogg"
24 else
25    FILE="$*"
26 fi
27
28 if ! [ -r "$FILE" ] ; then
29    echo "Sorry, /usr/share/grml/effect.ogg of package grml-files not available.">&2
30    exit 1
31 fi
32
33 echo "$PN - trying to play $FILE with $PLAYER
34
35 You do not hear anything? Make sure volume is not turned off.
36 Adjust mixer settings via aumix or alsamixer.
37
38 Tip: $PN supports some options.
39 Just provide the file(s) you want to play as argument(s),
40 adjust player which should be used for playing the files
41 via environment variable PLAYER. Usage example:
42
43   PLAYER=mplayer $PN /usr/share/grml/effect.ogg /another/file/to/play.mp3
44 "
45
46 $PLAYER $FILE && echo "It looks like sound works for you. :-)" || echo "problems with sound? :-("
47
48 ## END OF FILE #################################################################