this patch replaces dialog where possible and where inconvenient (menu
selection) just says "pick the first option".

i do not know - and do not care - what happens if there are no PCI
things found or if there is more than one.

this patch is against sarge alsaconf.  only the options bit fails
against unstable alsaconf due to additional options which have been
added to getopt.

l.

-- 
--
<a href="http://lkcl.net";>http://lkcl.net</a>
--
--- /usr/sbin/alsaconf  2005-06-28 18:46:23.000000000 +0100
+++ alsaconf    2005-07-27 13:50:55.000000000 +0100
@@ -93,11 +93,13 @@
   -P|--listprobe list the supported legacy card modules
   -c|--config file
                  specify the module config file
+  -U|--safe-unattented
+                 install without asking questions and don't do legacy!
   -h|--help      what you're reading"
     exit 1
 }
 
-OPTS=`getopt -o lmL:hp:Pu:g:d:rs:c: --long 
legacy,modinfo,log:,help,probe:,listprobe,uid:,gid:,devmode:,strict,sound:,config:
 -n alsaconf -- "$@"` || exit 1
+OPTS=`getopt -o UlmL:hp:Pu:g:d:rs:c: --long 
legacy,modinfo,log:,safe-unattented,help,probe:,listprobe,uid:,gid:,devmode:,strict,sound:,config:
 -n alsaconf -- "$@"` || exit 1
 eval set -- "$OPTS"
 
 do_legacy_only=0
@@ -108,6 +110,7 @@
 LOGFILE=""
 TESTSOUND="/usr/share/sounds/alsa/test.wav"
 try_all_combination=0
+INTERACTIVE="y";
 
 # legacy support
 LEGACY_CARDS="opl3sa2 cs4236 cs4232 cs4231 es18xx es1688 sb16 sb8"
@@ -139,6 +142,8 @@
        alsa_uid=0; alsa_gid=17; alsa_mode=0660; shift;;
     -c|--config)
        cfgfile="$2"; shift 2;;
+    -U|--safe-unattended)
+        INTERACTIVE="n"; SAFE_UNATTENDED="y"; shift;;
     --) shift ; break ;;
     *) usage ; exit 1 ;;
     esac
@@ -212,6 +217,37 @@
 fi
 fi
 
+if [ "$INTERACTIVE" == "n" ]; then
+           unattended_wrapper() {
+             #echo $1 $2 $3 $4 $5 $6 $7 $8
+             X1="$1"
+             X2="$2"
+             X3=$3
+             if [ $1 = --title ]; then
+              
+               if [ $2 = "WARNING" ]; then
+                       # --title "WARNING" is for legacy ISA - put "NO!!!"
+                       echo $4 - NO
+                       return 1
+               elif [ $3 = --menu ]; then
+                       return $8
+               fi
+             elif [ $1 = --yesno ]; then
+               echo $2 - YES
+               # assume yes for everything else
+               return 0
+             elif [ $1 = --gauge ]; then
+               echo whiptail...
+               shift 3
+               whiptail "$X1" "$X2" $X3 "$@"
+             else
+               # dunno yet
+               return 0
+             fi
+           }
+           DIALOG=unattended_wrapper
+
+else
 # Check for dialog, whiptail, gdialog, awk, ... ?
 if which dialog > /dev/null; then
     DIALOG=dialog
@@ -234,6 +270,8 @@
     exit 1
   fi
 fi
+fi
+
 if which awk > /dev/null; then :
 else
   xecho "Error, awk not found. Can't continue."
@@ -1289,8 +1327,13 @@
          Following card(s) are found on your system.
          Choose a soundcard to configure:
 ")
+    if [ "$INTERACTIVE" == "y" ]; then
     $DIALOG --title "$title" --menu "$msg" 17 76 8 "[EMAIL PROTECTED]" 2> 
$FOUND || acex 0
     card=`head -n 1 $FOUND`
+    else
+      card="${devs_found[0]}"
+      echo "Selecting first card $card"
+    fi
     if [ "$card" = "legacy" ]; then
        ac_config_legacy
     else

Reply via email to