[Debian-eeepc-commits] [SCM] Maintenance of eeepc-acpi-scripts debian package branch, master, updated. 930a0412c0d45ed4158146a7134cc61819493256

Damyan Ivanov dmn at debian.org
Mon Feb 2 20:39:10 UTC 2009


The following commit has been merged in the master branch:
commit 930a0412c0d45ed4158146a7134cc61819493256
Author: Raphael Geissert <atomo64 at gmail.com>
Date:   Thu Jan 29 20:35:18 2009 -0600

    Auto detect the playback devices and the playback switches.
    
    This finally resolves all the mess caused by different device names depending
    on the version of the alsa modules and machine model.
    
    Signed-off-by: Raphael Geissert <atomo64 at gmail.com>

diff --git a/debian/changelog b/debian/changelog
index e485181..54158ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
 eeepc-acpi-scripts (1.0.12) UNRELEASED; urgency=low
 
+  [ Darren Salt ]
   * Detect who's running an X session by looking for a controlling process
     with DISPLAY set in its environment.
     This has a useful side effect: status changes can be displayed even when
@@ -9,6 +10,10 @@ eeepc-acpi-scripts (1.0.12) UNRELEASED; urgency=low
   * Give immediate indication of pressing of Fn-F2.
   * The same ACPI key code may be used for wireless on as well as wireless off.
 
+  [ Raphael Geissert ]
+  * Auto detect the playback devices and the playback switches
+    Closes: #513552 -- Please auto detect the sound devices
+
  -- Darren Salt <linux at youmustbejoking.demon.co.uk>  Mon, 02 Feb 2009 16:55:55 +0000
 
 eeepc-acpi-scripts (1.0.11) unstable; urgency=low
diff --git a/debian/eeepc-acpi-scripts.default b/debian/eeepc-acpi-scripts.default
index 1e5f706..0cd0f81 100644
--- a/debian/eeepc-acpi-scripts.default
+++ b/debian/eeepc-acpi-scripts.default
@@ -3,9 +3,15 @@
 ENABLE_OSD='no'
 OSD_FONT='DejaVuSans 36'
 
-# lookup the following values by using amixer if they don't work for you
-VOLUME_LABEL='LineOut'
-HEADPHONE_LABEL='iSpeaker'
+# Leave these empty to attempt to autoconfigure. If they don't work for you
+# lookup the following values by using amixer
+SOUND_LABEL=
+SOUND_SWITCH=
+
+# Set to 'yes' to display detailed information when the volup and voldown
+# hotkeys are pressed but the volume percentage of all the playback devices
+# is not the same
+DETAILED_SOUND_INFO=no
 
 # These are the switches for xrandr --output VGA and --output LVDS
 # respectively when Fn-F5 is used to select VGA mode.
diff --git a/etc/acpi/actions/volume.sh b/etc/acpi/actions/volume.sh
index 904d71d..a8b012a 100755
--- a/etc/acpi/actions/volume.sh
+++ b/etc/acpi/actions/volume.sh
@@ -11,6 +11,7 @@ DEFAULT=/etc/default/$PKG
 if [ -e "$DEFAULT" ]; then . "$DEFAULT"; fi
 . $FUNC_LIB
 . /etc/acpi/lib/notify.sh
+. /etc/acpi/lib/sound.sh
 action=$1
 
 usage() {
@@ -27,32 +28,58 @@ if ! [ -x $AMIXER ]; then
     exit 1
 fi
 
+configureSound
+
 show_muteness() {
-    status=$($AMIXER get $VOLUME_LABEL | sed -n '/%/{s/.*\[\(on\|off\)\].*/\u\1/p;q}')
-    notify audio "Audio $status"
+    local label msg status all_equal=1 current
+    for label in $SOUND_SWITCH; do
+	current=$($AMIXER get $label |
+		    sed -n 's/.*\[\(on\|off\)\].*/\1/;ta;d;:a;p;q')
+	[ "$status" ] || status="$current"
+	[ "$status" = "$current" ] || all_equal=
+	msg="$msg $current ($label)"
+    done
+    if [ "$all_equal" ]; then
+	msg="$status"
+    fi
+    notify audio "Audio $msg"
 }
 
 show_volume() {
-    percent=$($AMIXER get $VOLUME_LABEL | sed -n '/%/{s/.*\[\(.*\)%\].*/\1/p;q}')
-    notify audio "Volume $percent"
+    local label msg percent all_equal=1 current
+    for label in $SOUND_LABEL; do
+	current=$($AMIXER get $label |
+		    sed -n '/%/{s/.*\[\(.*\)%\].*/\1/p;q}')
+	[ "$percent" ] || percent="$current"
+	[ "$percent" = "$current" ] || all_equal=
+	msg="$msg $current% ($label)"
+	if [ "$DETAILED_SOUND_INFO" != 'yes' ]; then
+	    break
+	fi
+    done
+    if [ "$all_equal" ]; then
+	msg="$percent%"
+    fi
+    notify audio "Volume $msg"
 }
 
 case "$action" in
     toggle)
-        # muting $VOLUME_LABEL affects the headphone jack but not the speakers
-        $AMIXER -q set $VOLUME_LABEL toggle
-        # muting $HEADPHONE_LABEL affects the speakers but not the headphone jack
-        $AMIXER -q set $HEADPHONE_LABEL toggle
+        for label in $SOUND_SWITCH; do
+            $AMIXER -q set $label toggle
+        done
         show_muteness
         ;;
     down)
-        amixer -q set $VOLUME_LABEL 2- unmute
-        amixer -q set $HEADPHONE_LABEL unmute
+        for label in $SOUND_LABEL; do
+            $AMIXER -q set $label 2%- unmute
+        done
         show_volume
         ;;
     up)
-        amixer -q set $VOLUME_LABEL 2+ unmute
-        amixer -q set $HEADPHONE_LABEL unmute
+        for label in $SOUND_LABEL; do
+            $AMIXER -q set $label 2%+ unmute
+        done
         show_volume
         ;;
     *)
diff --git a/etc/acpi/lib/sound.sh b/etc/acpi/lib/sound.sh
new file mode 100644
index 0000000..440b5d0
--- /dev/null
+++ b/etc/acpi/lib/sound.sh
@@ -0,0 +1,14 @@
+
+configureSound() {
+
+    [ "$SOUND_LABEL" ] || {
+	 SOUND_LABEL="$($AMIXER | grep -B1 pvolume |
+			sed -r "s/^(.*'([^']+)'.*|[^']+())$/\\2/")"
+    }
+
+    [ "$SOUND_SWITCH" ] || {
+	 SOUND_SWITCH="$($AMIXER | grep -B1 pswitch |
+			sed -r "s/^(.*'([^']+)'.*|[^']+())$/\\2/")"
+    }
+
+}

-- 
Maintenance of eeepc-acpi-scripts debian package



More information about the Debian-eeepc-commits mailing list