~vcs-imports/alsa-utils/trunk

« back to all changes in this revision

Viewing changes to alsaconf/alsaconf.in

  • Committer: Takashi Iwai
  • Date: 2004-12-29 16:10:47 UTC
  • Revision ID: git-v1:0aa74e8d4d5065c1ba310808080fe0c303bd820e
i18nize alsaconf

alsaconf is i18nized.  Only ja.po is provided, so far.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#  (at your option) any later version.
18
18
#
19
19
 
 
20
export TEXTDOMAIN=alsaconf
 
21
 
20
22
prefix=@prefix@
21
23
exec_prefix=@exec_prefix@
22
24
bindir=@bindir@
23
25
sbindir=@sbindir@
24
26
version=@VERSION@
 
27
USE_NLS=@USE_NLS@
 
28
 
 
29
# i18n stuff
 
30
if test "$USE_NLS" = "yes" && which gettext > /dev/null; then
 
31
  xecho() {
 
32
    gettext -s "$*"
 
33
  }
 
34
else
 
35
  xecho() {
 
36
    echo "$*"
 
37
  }
 
38
  gettext() {
 
39
    echo -n "$*"
 
40
  }
 
41
fi
 
42
xmsg() {
 
43
  msg=$(gettext "$1")
 
44
  shift
 
45
  printf "$msg" $*
 
46
}
25
47
 
26
48
# Check for GNU/Linux distributions
27
49
if [ -f /etc/SuSE-release -o -f /etc/UnitedLinux-release ]; then
48
70
unset prog path
49
71
 
50
72
usage() {
51
 
    echo "ALSA configurator version $version"
52
 
    echo "usage: alsaconf [options]"
53
 
    echo "  -l|--legacy    check only legacy non-isapnp cards"
54
 
    echo "  -m|--modinfo   read module descriptions instead of reading card db"
55
 
    echo "  -s|--sound wav-file"
56
 
    echo "                 use the specified wav file as a test sound"
57
 
    echo "  -u|--uid uid   set the uid for the ALSA devices (default = 0) [obsoleted]"
58
 
    echo "  -g|--gid gid   set the gid for the ALSA devices (default = 0) [obsoleted]"
59
 
    echo "  -d|--devmode mode"
60
 
    echo "                 set the permission for ALSA devices (default = 0666) [obs.]"
61
 
    echo "  -r|--strict    set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]"
62
 
    echo "  -L|--log file  logging on the specified file (for debugging purpose only)"
63
 
    echo "  -p|--probe card-name"
64
 
    echo "                 probe a legacy non-isapnp card and print module options"
65
 
    echo "  -P|--listprobe list the supported legacy card modules"
66
 
    echo "  -c|--config file"
67
 
    echo "                 specify the module config file"
68
 
    echo "  -h|--help      what you're reading"
 
73
    xecho "ALSA configurator"
 
74
    echo "  version $version"
 
75
    xecho "usage: alsaconf [options]
 
76
  -l|--legacy    check only legacy non-isapnp cards
 
77
  -m|--modinfo   read module descriptions instead of reading card db
 
78
  -s|--sound wav-file
 
79
                 use the specified wav file as a test sound
 
80
  -u|--uid uid   set the uid for the ALSA devices (default = 0) [obsoleted]
 
81
  -g|--gid gid   set the gid for the ALSA devices (default = 0) [obsoleted]
 
82
  -d|--devmode mode
 
83
                 set the permission for ALSA devices (default = 0666) [obs.]
 
84
  -r|--strict    set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]
 
85
  -L|--log file  logging on the specified file (for debugging purpose only)
 
86
  -p|--probe card-name
 
87
                 probe a legacy non-isapnp card and print module options
 
88
  -P|--listprobe list the supported legacy card modules
 
89
  -c|--config file
 
90
                 specify the module config file
 
91
  -h|--help      what you're reading"
69
92
    exit 1
70
93
}
71
94
 
118
141
 
119
142
# Check for root privileges
120
143
if [ `id -u` -ne 0 ]; then
121
 
  echo "You must be root to use this script."
 
144
  xecho "You must be root to use this script."
122
145
  exit 1
123
146
fi
124
147
 
126
149
# check the snd_ prefix for ALSA module options
127
150
# snd_ prefix is obsoleted since 0.9.0rc4.
128
151
#
129
 
if modinfo -p snd | grep -q snd_ ; then
 
152
if /sbin/modinfo -p snd | grep -q snd_ ; then
130
153
  mpfx="snd_"
131
154
else
132
155
  mpfx=""
133
156
fi
134
157
 
135
158
alsa_device_opts=""
136
 
if modinfo -p snd | grep -q uid ; then
 
159
if /sbin/modinfo -p snd | grep -q uid ; then
137
160
  if [ x"$alsa_uid" != x0 ]; then
138
161
    alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid"
139
162
  fi
141
164
    alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid"
142
165
  fi
143
166
fi
144
 
if modinfo -p snd | grep -q device_mode ; then
 
167
if /sbin/modinfo -p snd | grep -q device_mode ; then
145
168
  if [ x"$alsa_mode" != x0 ]; then
146
169
    alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode"
147
170
  fi
160
183
# cfgout = new config file to write the sound setting (if different from $cfgfile)
161
184
if [ -n "$cfgfile" ]; then
162
185
  if [ ! -r "$cfgfile" ]; then
163
 
    echo "ERROR: The config file $cfgfile doesn't exist."
 
186
    xecho "ERROR: The config file doesn't exist: "
 
187
    echo $cfgfile
164
188
    exit 1
165
189
  fi
166
190
else
185
209
 
186
210
# Check for dialog, whiptail, gdialog, awk, ... ?
187
211
if which dialog > /dev/null; then
188
 
  DIALOG=dialog
 
212
    DIALOG=dialog
189
213
else
190
214
  if which whiptail > /dev/null; then
191
215
    whiptail_wrapper() {
201
225
    }
202
226
    DIALOG=whiptail_wrapper
203
227
  else
204
 
    echo "Error, dialog or whiptail not found."
 
228
    xecho "Error, dialog or whiptail not found."
205
229
    exit 1
206
230
  fi
207
231
fi
208
232
if which awk > /dev/null; then :
209
233
else
210
 
  echo "Error, awk not found. Can't continue."
 
234
  xecho "Error, awk not found. Can't continue."
211
235
  exit 1
212
236
fi
213
237
 
302
326
 
303
327
# INTRO
304
328
intro() {
305
 
$DIALOG --msgbox "
 
329
  local msg=$(xmsg "
306
330
                   ALSA  CONFIGURATOR
307
 
                          v$version
 
331
                   version %s
308
332
 
309
333
            This script is a configurator for
310
334
    Advanced Linux Sound Architecture (ALSA) driver.
312
336
 
313
337
  If ALSA is already running, you should close all sound
314
338
  apps now and stop the sound driver.
315
 
  alsaconf will try to do this, but it's not 100% sure.
316
 
" 20 63 || acex 0
 
339
  alsaconf will try to do this, but it's not 100%% sure." $version)
 
340
  $DIALOG --msgbox "$msg" 20 63 || acex 0
317
341
}
318
342
 
319
343
# FAREWELL
320
344
farewell() {
321
 
$DIALOG --msgbox "
 
345
  local msg=$(gettext "
322
346
 
323
 
     $*
 
347
     OK, sound driver is configured.
324
348
 
325
349
                  ALSA  CONFIGURATOR
326
350
 
327
351
          will prepare the card for playing now.
328
352
 
329
 
     Now I'll run '`basename $rcalsasound` start', then I'll use
 
353
     Now I'll run alsasound init script, then I'll use
330
354
     amixer to raise the default volumes.
331
355
     You can change the volume later via a mixer
332
356
     program such as alsamixer or gamix.
333
 
 
334
 
" 17 60 || acex 0
 
357
  
 
358
  ")
 
359
  $DIALOG --msgbox "$msg" 17 60 || acex 0
335
360
}
336
361
 
337
362
# Exit function
379
404
 
380
405
TMP=`mktemp -q /tmp/alsaconf.XXXXXX`
381
406
if [ $? -ne 0 ]; then
382
 
        echo "$0: Can't create temp file, exiting..."
 
407
        xecho "Can't create temp file, exiting..."
383
408
        exit 1
384
409
fi
385
410
addcfg=`mktemp -q /tmp/alsaconf.XXXXXX`
386
411
if [ $? -ne 0 ]; then
387
 
        echo "$0: Can't create temp file, exiting..."
 
412
        xecho "Can't create temp file, exiting..."
388
413
        exit 1
389
414
fi
390
415
FOUND=`mktemp -q /tmp/alsaconf.XXXXXX`
391
416
if [ $? -ne 0 ]; then
392
 
        echo "$0: Can't create temp file, exiting..."
 
417
        xecho "Can't create temp file, exiting..."
393
418
        exit 1
394
419
fi
395
420
DUMP=`mktemp -q /tmp/alsaconf.XXXXXX`
396
421
if [ $? -ne 0 ]; then
397
 
        echo "$0: Can't create temp file, exiting..."
 
422
        xecho "Can't create temp file, exiting..."
398
423
        exit 1
399
424
fi
400
425
 
488
513
        fi
489
514
    fi
490
515
    if [ $use_modinfo_db = 1 ]; then
491
 
        echo "Building card database.."
 
516
        xecho "Building card database.."
492
517
        build_card_db $CARDID_DB
493
518
    fi
494
519
    if [ ! -r $CARDID_DB ]; then
495
 
        echo "No card database is found.."
 
520
        xecho "No card database is found.."
496
521
        exit 1
497
522
    fi
498
523
    ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`
499
524
 
 
525
    msg=$(gettext "Searching sound cards")
500
526
    awk '
501
527
BEGIN {
502
528
        format="%-40s %s\n";
523
549
        if (system (x) == 0)
524
550
                printf "%s %s\n", $2, driver >>"'"$FOUND"'"
525
551
}' < $CARDID_DB |\
526
 
    $DIALOG --gauge "Searching sound cards" 6 40 0
 
552
    $DIALOG --gauge "$msg" 6 40 0
527
553
 
528
554
    #
529
555
    # PowerMac
547
573
        $lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. Multimedia audio controller: //g'
548
574
        return
549
575
    elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then
550
 
        cardname=`grep '^Card [0-9]\+ '\'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
 
576
        cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`
551
577
        echo $cardname
552
578
    else
553
579
        echo $1
563
589
    CARD_OPTS="${*:2}"
564
590
 
565
591
    if [ -n "$cfgout" ]; then
566
 
        $DIALOG --yesno "
567
 
Configuring $CARD_DRIVER
568
 
Do you want to modify ${cfgout} (and ${cfgfile} if present)?" 8 50 || acex 0
 
592
        msg=$(xmsg "
 
593
Configuring %s
 
594
Do you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile)
 
595
        $DIALOG --yesno "$msg" 8 50 || acex 0
569
596
    else
570
 
        $DIALOG --yesno "
571
 
Configuring $CARD_DRIVER
572
 
Do you want to modify ${cfgfile}?" 8 50 || acex 0
 
597
        msg=$(xmsg "
 
598
Configuring %s
 
599
Do you want to modify %s?" $CARD_DRIVER $cfgfile)
 
600
        $DIALOG --yesno "$msg" 8 50 || acex 0
573
601
    fi
574
602
    clear
575
603
 
643
671
        cp -f $TMP /var/lib/YaST/unique.inf
644
672
    fi
645
673
 
646
 
    farewell "OK, driver $CARD_DRIVER is configured."
 
674
    farewell
647
675
    clear
648
676
    if [ "$distribution" = "gentoo" ]; then
649
 
      echo Running modules-update...
 
677
      xecho "Running modules-update..."
650
678
      modules-update
651
679
    elif [ "$distribution" = "debian" ]; then
652
 
      echo Running update-modules...
 
680
      xecho "Running update-modules..."
653
681
      update-modules
654
682
    fi
655
683
    echo Loading driver...
661
689
        set_mixers
662
690
    fi
663
691
    if [ -f $TESTSOUND ]; then
664
 
      if $DIALOG --yesno "
 
692
      msg=$(gettext "
665
693
       The mixer is set up now for for playing.
666
694
       Shall I try to play a sound sample now?
667
695
 
669
697
If you have a big amplifier, lower your volumes or say no.
670
698
    Otherwise check that your speaker volume is open,
671
699
          and look if you can hear test sound.
672
 
" 13 65 
 
700
")
 
701
      if $DIALOG --yesno "$msg" 13 65 
673
702
      then
674
703
          clear
675
704
          echo
677
706
      fi
678
707
    fi
679
708
    if [ ! -r /etc/asound.state ]; then
680
 
        echo "Saving the mixer setup used for this in /etc/asound.state."
 
709
        xecho "Saving the mixer setup used for this in /etc/asound.state."
681
710
        $sbindir/alsactl store
682
711
    fi
683
712
    clear
684
 
    cat <<END
 
713
    xecho "
685
714
===============================================================================
686
715
 
687
716
 Now ALSA is ready to use.
689
718
 
690
719
 Have a lot of fun!
691
720
 
692
 
END
 
721
"
693
722
}
694
723
 
695
 
 
696
724
#
697
725
# probe legacy ISA cards
698
726
#
886
914
 
887
915
# check if the option $2 exists in card $1: set value $3
888
916
ac_check_option () {
889
 
    if modinfo -p snd-$1 | grep $2 > /dev/null 2>&1 ; then
 
917
    if /sbin/modinfo -p snd-$1 | grep $2 > /dev/null 2>&1 ; then
890
918
      echo "$2=$3"
891
919
    fi
892
920
}
1014
1042
}
1015
1043
 
1016
1044
ac_config_legacy () {
1017
 
 
1018
 
    $DIALOG --title "WARNING" --yesno "
 
1045
   title=$(gettext "WARNING")
 
1046
   msg=$(gettext "
1019
1047
   Probing legacy ISA cards might make
1020
1048
   your system unstable.
1021
1049
 
1022
1050
        Are you sure to proceed?
1023
1051
 
1024
 
" 10 50 || acex 0
 
1052
")
 
1053
    $DIALOG --title "$title" --yesno "$msg" 10 50 || acex 0
1025
1054
 
1026
1055
    if [ x"$1" = x ]; then
1027
1056
        probe_list="$LEGACY_CARDS"
1037
1066
        fi
1038
1067
    done
1039
1068
    if [ x$menu_args = x ]; then
1040
 
        $DIALOG --msgbox "No legacy drivers are available
1041
 
   for your machine" 5 50
 
1069
        msg=$(gettext "No legacy drivers are available
 
1070
   for your machine")
 
1071
        $DIALOG --msgbox "$msg" 5 50
1042
1072
        return 1
1043
1073
    fi
1044
 
    $DIALOG --title "Driver Selection" --checklist \
1045
 
"           Probing legacy ISA cards
 
1074
    title=$(gettext "Driver Selection")
 
1075
    msg=$(gettext "           Probing legacy ISA cards
1046
1076
 
1047
 
        Please select the drivers to probe:" \
 
1077
        Please select the drivers to probe:")
 
1078
    $DIALOG --title "$title" --checklist "$msg" \
1048
1079
        17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0
1049
1080
 
1050
1081
    if [ $try_all_combination != 1 ]; then
1051
 
        if $DIALOG --yesno "
 
1082
        msg=$(gettext "
1052
1083
 Shall I try all possible DMA and IRQ combinations?
1053
1084
 With this option, some unconventional configuration
1054
 
 might be found, but it will take much longer time." 10 60
 
1085
 might be found, but it will take much longer time.")
 
1086
        if $DIALOG --yesno "$msg" 10 60
1055
1087
            then
1056
1088
            try_all_combination=1
1057
1089
        fi
1058
1090
    fi
1059
1091
 
1060
 
    echo "Probing legacy cards..   This may take a few minutes.."
1061
 
    echo -n "Probing: "
 
1092
    xecho "Probing legacy cards..   This may take a few minutes.."
 
1093
    echo -n $(gettext "Probing: ")
1062
1094
    cards=`cat $FOUND | tr -d \"`
1063
1095
    for card in $cards; do
1064
1096
        echo -n " $card"
1065
1097
        ac_opts=""
1066
1098
        if eval ac_try_card_$card ; then
1067
 
            echo ' : FOUND!!'
 
1099
            xecho " : FOUND!!"
1068
1100
            ac_config_card $card $ac_opts
1069
1101
            return 0
1070
1102
        fi
1071
1103
    done
1072
1104
    echo
1073
 
    $DIALOG --title "Result" --msgbox "No legacy cards found" 5 50
 
1105
    title=$(gettext "Result")
 
1106
    msg=$(gettext "No legacy cards found")
 
1107
    $DIALOG --title "$title" --msgbox "$msg" 5 50
1074
1108
    return 1
1075
1109
}
1076
1110
 
1124
1158
    #
1125
1159
    if [ ${devs_found[0]} = cs46xx ]; then
1126
1160
        if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then
1127
 
            if $DIALOG --yesno "
 
1161
            msg=$(gettext "
1128
1162
 Looks like you having a Thinkpad 600E or 770 notebook.
1129
1163
 On this notebook, CS4236 driver should be used
1130
1164
 although CS46xx chip is detected.
1131
1165
 
1132
1166
 Shall I try to snd-cs4236 driver and probe
1133
 
 the legacy ISA configuration?" 13 60
 
1167
 the legacy ISA configuration?")
 
1168
            if $DIALOG --yesno "$msg" 13 60
1134
1169
            then
1135
1170
                try_all_combination=1
1136
1171
                ac_config_legacy cs4236
1137
1172
                exit 0
1138
1173
            fi
1139
1174
        elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then
1140
 
            if $DIALOG --yesno "
 
1175
            msg=$(gettext "
1141
1176
 Looks like you having a Dell Dimension machine.
1142
1177
 On this machine, CS4232 driver should be used
1143
1178
 although CS46xx chip is detected.
1144
1179
 
1145
1180
 Shall I try to snd-cs4232 driver and probe
1146
 
 the legacy ISA configuration?" 13 60
 
1181
 the legacy ISA configuration?")
 
1182
            if $DIALOG --yesno "$msg" 13 60
1147
1183
            then
1148
1184
                try_all_combination=1
1149
1185
                ac_config_legacy cs4232
1153
1189
    fi
1154
1190
   
1155
1191
    devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips")
1156
 
    $DIALOG --title "Soundcard Selection" --menu "
 
1192
    title=$(gettext "Soundcard Selection")
 
1193
    msg=$(gettext "
1157
1194
         Following card(s) are found on your system.
1158
1195
         Choose a soundcard to configure:
1159
 
" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
 
1196
")
 
1197
    $DIALOG --title "$title" --menu "$msg" 17 76 8 "${devs_found[@]}" 2> $FOUND || acex 0
1160
1198
    card=`head -n 1 $FOUND`
1161
1199
    if [ "$card" = "legacy" ]; then
1162
1200
        ac_config_legacy
1165
1203
    fi
1166
1204
    exit 0
1167
1205
else
1168
 
    if $DIALOG --yesno "
 
1206
    msg=$(gettext "
1169
1207
        No supported PnP or PCI card found.
1170
1208
 
1171
1209
 Would you like to probe legacy ISA sound cards/chips?
1172
1210
 
1173
 
" 9 60 ; then
 
1211
")
 
1212
    if $DIALOG --yesno "$msg" 9 60 ; then
1174
1213
        ac_config_legacy
1175
1214
        exit 0
1176
1215
    fi