[PATCH] Can leave volume handling to desktop environment

Tomaz Solc tomaz.solc at tablix.org
Sat Dec 13 17:23:52 UTC 2008


If gnome-settings-daemon is running or if user has specifically
requested this in /etc/defaults/eeepc-acpi-scripts, events generated
by volume hotkeys are simply translated to proper key presses
with acpi_fakekey.

Note that this requires acpi_fakekey tool and
/usr/share/acpi-support/key-constants to be present on the system.
---
 debian/README.Debian       |    3 ++
 etc/acpi/actions/volume.sh |   48 +++++++++++++++++++++++++++++++++----------
 2 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/debian/README.Debian b/debian/README.Debian
index 69007cf..9e766aa 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -12,6 +12,9 @@ package, we still search a sane solution for this. To get the correct values
 for these labels check the output of "amixer". On some Eee PC's the correct
 values are 'Front' and 'Headphone'.
 
+If you want to leave volume management to any desktop environment you might
+be running, set HANDLE_VOLUME to 0.
+
 To get nifty osd overlays on changing the volume, switching on wireless
 etc. change ENABLE_OSD to yes in /etc/default/eeepc-acpi-scripts. Make sure you
 have aosd-cat installed then.
diff --git a/etc/acpi/actions/volume.sh b/etc/acpi/actions/volume.sh
index 904d71d..5a4d620 100755
--- a/etc/acpi/actions/volume.sh
+++ b/etc/acpi/actions/volume.sh
@@ -13,6 +13,18 @@ if [ -e "$DEFAULT" ]; then . "$DEFAULT"; fi
 . /etc/acpi/lib/notify.sh
 action=$1
 
+if [ ! "$HANDLE_VOLUME" ]; then
+	if pidof gnome-settings-daemon > /dev/null; then
+		HANDLE_VOLUME="0"
+	else
+		HANDLE_VOLUME="1"
+	fi
+fi
+
+if [ "$HANDLE_VOLUME" = "0" ]; then
+	. "/usr/share/acpi-support/key-constants"
+fi
+   
 usage() {
     cat <<EOF >&2
 Usage: $0 up|down|toggle
@@ -39,21 +51,35 @@ show_volume() {
 
 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
-        show_muteness
+	if [ "$HANDLE_VOLUME" = "1" ]; then
+        	# 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
+        	show_muteness
+	else
+		acpi_fakekey $KEY_MUTE
+	fi
         ;;
     down)
-        amixer -q set $VOLUME_LABEL 2- unmute
-        amixer -q set $HEADPHONE_LABEL unmute
-        show_volume
+	if [ "$HANDLE_VOLUME" = "1" ]; then
+        	amixer -q set $VOLUME_LABEL 2- unmute
+	        amixer -q set $HEADPHONE_LABEL unmute
+       		show_volume
+	else
+		acpi_fakekey $KEY_VOLUMEDOWN
+	fi
         ;;
     up)
-        amixer -q set $VOLUME_LABEL 2+ unmute
-        amixer -q set $HEADPHONE_LABEL unmute
-        show_volume
+	if [ "$HANDLE_VOLUME" = "1" ]; then
+        	amixer -q set $VOLUME_LABEL 2+ unmute
+	        amixer -q set $HEADPHONE_LABEL unmute
+	        show_volume
+	else
+		acpi_fakekey $KEY_VOLUMEUP
+	fi
         ;;
     *)
         usage
-- 
1.5.6.5



--------------030305000305040704090204--



More information about the Debian-eeepc-devel mailing list