-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

>       I tested Tomaz Solc's patch [2], taking /usr/bin/acpi_fakekey and
>       /usr/share/acpi-support/key-constants from acpi-suppor: they work
>       as expected, thanks Tomaz!  I am not sure I will have the time to
>       adapt them to the brightness keys, but IMHO we should.

Great. I'm glad to hear that.

Here's an updated patch which fixes a problem where notifications
wouldn't appear after a reboot (X screen detection was a bit off)

Is there any chance this could be merged into the official repository?

Best regards
Tomaž
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklWDygACgkQsAlAlRhL9q/y5ACeOWCSm0I3nuOUpOhjDg7scKkh
UFYAn2QPdQGSHPrafeiNyxvLQXaHprLi
=lERB
-----END PGP SIGNATURE-----
>From 6dc2e3a903c09ed5f7e193ba4e7120e1267a7eed Mon Sep 17 00:00:00 2001
From: Tomaz Solc <[email protected]>
Date: Sat, 13 Dec 2008 18:23:52 +0100
Subject: [PATCH] Can leave volume handling to desktop environment

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..22b88c4 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
+		/usr/bin/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
+		/usr/bin/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
+		/usr/bin/acpi_fakekey $KEY_VOLUMEUP
+	fi
         ;;
     *)
         usage
-- 
1.5.6.5

>From 1facb33dd9c7c31af5b8a044c50a28d59639561e Mon Sep 17 00:00:00 2001
From: Tomaz Solc <[email protected]>
Date: Sat, 27 Dec 2008 12:04:34 +0100
Subject: [PATCH] Display notifications with libnotify, if available

If notify-send utility is found, notifications are displayed
through that, instead of using GNOME OSD.
---
 debian/README.Debian       |   10 +++++--
 debian/control             |    2 +-
 etc/acpi/actions/hotkey.sh |   19 +++++++-------
 etc/acpi/actions/volume.sh |    6 +++-
 etc/acpi/lib/notify.sh     |   57 ++++++++++++++++++++++++++++++++++----------
 5 files changed, 66 insertions(+), 28 deletions(-)

diff --git a/debian/README.Debian b/debian/README.Debian
index 9e766aa..b1068c1 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -15,9 +15,13 @@ 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.
+You will get notifications of changes in the hardware through libnotify, 
+if available. If you do not want that, set ENABLE_LIBNOTIFY to no.
+
+Alternatively, you can get the same notifications through GNOME OSD. 
+To disable that, set ENABLE_OSD to no in /etc/default/eeepc-acpi-scripts.
+
+You need to have aosd-cat installed in order for GNOME OSD to work.
 
 [0] http://wiki.debian.org/DebianEeePC
 
diff --git a/debian/control b/debian/control
index a017a99..ce511fa 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,7 @@ Package: eeepc-acpi-scripts
 Architecture: all
 Conflicts: acpi-support
 Depends: acpid (>= 1.0.4), acpi-support-base, pm-utils
-Recommends: alsa-utils
+Recommends: alsa-utils, libnotify-bin
 Suggests: aosd-cat, ttf-dejavu | ttf-bitstream-vera | ttf-freefont
  | gsfonts-x11 | ttf-mscorefonts-installer | ttf-liberation,
  gnome-osd
diff --git a/etc/acpi/actions/hotkey.sh b/etc/acpi/actions/hotkey.sh
index a574911..d0a4960 100755
--- a/etc/acpi/actions/hotkey.sh
+++ b/etc/acpi/actions/hotkey.sh
@@ -27,11 +27,12 @@ handle_volume_down() {
 show_wireless() {
     detect_wlan
     if grep -q $WLAN_IF /proc/net/wireless; then
-	status=On
+        status=On
+        notify wireless "Wireless On" "Wireless LAN module has been turned on"
     else
-	status=Off
+        status=Off
+        notify wireless "Wireless Off" "Wireless LAN module has been turned off"
     fi
-    notify wireless "Wireless $status"
 }
 
 handle_blank_screen() {
@@ -46,9 +47,9 @@ handle_blank_screen() {
 
 show_bluetooth() {
     if bluetooth_is_on; then
-	notify bluetooth 'Bluetooth On'
+	notify bluetooth 'Bluetooth On' 'Bluetooth module has been turned on'
     else
-	notify bluetooth 'Bluetooth Off'
+	notify bluetooth 'Bluetooth Off' 'Bluetooth module has been turned off'
     fi
 }
 
@@ -58,15 +59,15 @@ handle_bluetooth_toggle() {
 	toggle_bluetooth
 	show_bluetooth
     else
-	notify error 'Bluetooth unavailable'
+	notify error 'Bluetooth unavailable' 'Bluetooth module is not available'
     fi
 }
 
 show_camera() {
     if camera_is_on; then
-	notify camera 'Camera Enabled'
+	notify camera 'Camera On' 'Integrated web camera has been turned on'
     else
-	notify camera 'Camera Disabled'
+	notify camera 'Camera Off' 'Integrated web camera has been turned off'
     fi
 }
 
@@ -76,7 +77,7 @@ handle_camera_toggle() {
 	toggle_camera
 	show_camera
     else
-	notify error 'Camera unavailable'
+	notify error 'Camera Unavailable' 'Integrated web camera is not available'
     fi
 }
 
diff --git a/etc/acpi/actions/volume.sh b/etc/acpi/actions/volume.sh
index 22b88c4..3d2d257 100755
--- a/etc/acpi/actions/volume.sh
+++ b/etc/acpi/actions/volume.sh
@@ -41,12 +41,14 @@ fi
 
 show_muteness() {
     status=$($AMIXER get $VOLUME_LABEL | sed -n '/%/{s/.*\[\(on\|off\)\].*/\u\1/p;q}')
-    notify audio "Audio $status"
+    ENABLE_LIBNOTIFY="no"
+    notify audio "Audio $status" "Audio $status"
 }
 
 show_volume() {
     percent=$($AMIXER get $VOLUME_LABEL | sed -n '/%/{s/.*\[\(.*\)%\].*/\1/p;q}')
-    notify audio "Volume $percent"
+    ENABLE_LIBNOTIFY="no"
+    notify audio "Volume $percent" "Volume $percent"
 }
 
 case "$action" in
diff --git a/etc/acpi/lib/notify.sh b/etc/acpi/lib/notify.sh
index 0156129..ce17404 100755
--- a/etc/acpi/lib/notify.sh
+++ b/etc/acpi/lib/notify.sh
@@ -2,20 +2,11 @@
 #
 # this file is to be sourced
 
-notify() {
+NOTIFYSEND="/usr/bin/notify-send"
+
+notify_gnome_osd() {
     CATEGORY=$1
     MSG=$2
-    if [ -n "$3" ]; then
-	echo "usage: notify 'catgory' 'message text'" > /dev/stderr
-	return 1
-    fi
-    echo "$MSG"  # for /var/log/acpid
-    if [ -S /tmp/.X11-unix/X0 ]; then
-        detect_x_display
-
-    if [ "x$ENABLE_OSD" = "xno" ]; then
-        return
-    fi
 
     OSD_SHOWN=
 
@@ -42,8 +33,48 @@ notify() {
 		echo "$MSG" | aosd_cat -n "$OSD_FONT" -f 100 -u 1000 -o 100 &
 	fi
     fi
+}
+
+notify_libnotify() {
+    CATEGORY=$1
+    SUMMARY=$2
+    MSG=$3
+
+    case "$CATEGORY" in    
+	"bluetooth")
+		ICON="/usr/share/icons/hicolor/scalable/apps/bluetooth.svg"
+                ;;
+	"wireless")
+		ICON="/usr/share/icons/gnome/scalable/devices/network-wireless.svg"
+                ;;
+        "camera")
+                ICON="/usr/share/icons/gnome/scalable/devices/camera-web.svg"
+                ;;
+    esac
+
+    if [ -f "$ICON" ]; then
+    	"$NOTIFYSEND" --icon "$ICON" "$SUMMARY" "$MSG"
     else
-	echo "$MSG" > /dev/console
+    	"$NOTIFYSEND" "$SUMMARY" "$MSG"
     fi
 }
 
+notify() {
+    if [ "$#" -ne 3 ]; then
+	echo "usage: notify 'category' 'summary' 'text" > /dev/stderr
+	return 1
+    fi
+    echo "$MSG"  # for /var/log/acpid
+
+    if [ -S /tmp/.X11-unix/X0 ]; then
+        detect_x_display
+
+        if [ "x$ENABLE_LIBNOTIFY" != "xno" -a -x "$NOTIFYSEND" ]; then
+            notify_libnotify "$@"
+        elif [ "x$ENABLE_OSD" != "xno" ]; then
+            notify_gnome_osd "$@"
+        fi
+    else
+	echo "$2" > /dev/console
+    fi
+}
-- 
1.5.6.5

_______________________________________________
Debian-eeepc-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/debian-eeepc-devel

Reply via email to