[Pkg-acpi-devel] Bug#561953: acpi-support: wireless control button does not work on Asus A3A

Jakub Adam jakub.adam at ktknet.cz
Mon Dec 21 14:04:49 UTC 2009


Subject: acpi-support: wireless control button does not work on Asus A3A
Package: acpi-support
Version: 0.130-1
Severity: normal
Tags: patch

Hi,

I had some trouble get wireless control button (Fn+F2) on my Asus A3A laptop to work and managed to wrote a patch for this functionality,
hope you find it useful.

I use ipw2200 driver with my wifi.

Basic changes done:

/usr/share/acpi-support/state-funcs
- /sys/class/net/*/wireless directory does not exist in my system, reading through some forum posts I found that this interface is deprecated,
so probably it was removed some time ago. As a workaround, I obtained names of wireless interfaces by parsing /proc/net/wireless file.

added new file /etc/acpi/events/asus-wireless-toggle
- event generated by the button was not recognized by acpid, this file handles the event calling /etc/acpi/asus-wireless.sh with no arguments


--- /usr/share/acpi-support/state-funcs	2009-12-20 21:45:57.000000000 +0100
+++ /home/haakon/state-funcs	2009-12-21 14:30:57.000000000 +0100
@@ -1,28 +1,30 @@
  # Paul Sladen, 2006-03-28, 2007-03-26
  # Library functions to check/change status of wireless

+IFACE_NAMES=`cut -d: -f1 -s /proc/net/wireless`
+
  # Return 0 if there is, allowing you to write   if isAnyWirelessPoweredOn; then ...
  isAnyWirelessPoweredOn()
  {
-    for DEVICE in /sys/class/net/* ; do
-	if [ -d $DEVICE/wireless ]; then
-	    for RFKILL in $DEVICE/phy80211/rfkill*/state $DEVICE/device/rfkill/rfkill*/state
-	    do
-		if [ -r "$RFKILL" ] && [ "$(cat "$RFKILL")" -eq 1 ]
-		then
-		    return 0
-		fi
-	    done
-	    # if any of the wireless devices are turned on then return success
-	    if [ -r $DEVICE/device/power/state ] && [ "`cat $DEVICE/device/power/state`" -eq 0 ]
-	    then
-		return 0
-	    fi
-	    if [ -r $DEVICE/device/rf_kill ] && [ "`cat $DEVICE/device/rf_kill`" -eq 0 ]
-	    then
-		return 0
-	    fi
-	fi
+    for NET_IF in $IFACE_NAMES ; do
+        DEVICE=/sys/class/net/$NET_IF
+
+        for RFKILL in $DEVICE/phy80211/rfkill*/state $DEVICE/device/rfkill/rfkill*/state
+        do
+            if [ -r "$RFKILL" ] && [ "$(cat "$RFKILL")" -eq 1 ]
+            then
+                return 0
+            fi
+        done
+        # if any of the wireless devices are turned on then return success
+        if [ -r $DEVICE/device/power/state ] && [ "`cat $DEVICE/device/power/state`" -eq 0 ]
+        then
+            return 0
+        fi
+        if [ -r $DEVICE/device/rf_kill ] && [ "`cat $DEVICE/device/rf_kill`" -eq 0 ]
+        then
+            return 0
+        fi
      done

      # otherwise return failure
@@ -35,75 +37,72 @@
  # will fail on >=2.6.18 kernels since upstream removed the functionality...
  toggleAllWirelessStates()
  {
-    for DEVICE in /sys/class/net/* ; do
-	if [ -d $DEVICE/wireless ] ; then
-	    # $DEVICE is a wireless device.
-	    NET_IF=`echo $DEVICE | cut -d \/ -f 5`
-
-	    FOUND=
-	    # Yes, that's right... the new interface reverses the truth values.
-	    ON=1
-	    OFF=0
-	    for CONTROL in $DEVICE/phy80211/rfkill*/state $DEVICE/device/rfkill/rfkill*/state; do
-		if [ -w "$CONTROL" ]; then
-		    FOUND=1
-
-		    if [ "$(cat "$CONTROL")" = "$ON" ] ; then
-			# It's powered on. Switch it off.
-			echo -n "$OFF" > "$CONTROL"
-		    else
-			# It's powered off. Switch it on.
-			echo -n "$ON" > "$CONTROL"
-		    fi
-		fi
-	    done
-	    # it might be safe to assume that a device only supports one
-	    # interface at a time; but just in case, we short-circuit
-	    # here to avoid toggling the power twice
-	    if [ -n "$FOUND" ]; then
-		continue
-	    fi
-
-	    ON=0
-	    OFF=1  # 1 for rf_kill, 2 for power/state
-	    for CONTROL in $DEVICE/device/rf_kill $DEVICE/device/power/state ; do
-		if [ -w $CONTROL ] ; then
-		    # We have a way of controlling the device, lets try
-		    if [ "`cat $CONTROL`" = 0 ] ; then
-			# It's powered on. Switch it off.
-			if echo -n $OFF > $CONTROL ; then
-			    ifdown "${NET_IF}"
-			    break
-			else
-			    OFF=2 # for power/state, second time around
-			fi
-		    else
-			# It's powered off. Switch it on.
-			if echo -n $ON > $CONTROL ; then
-			    ifup "${NET_IF}"
-			    if [ -x /sbin/wpa_cli ]; then
-				wpa_cli scan
-			    fi
-			    break
-			fi
-		    fi
-		fi
-	    done
-
-            # For madwifi we need to check "operstate" instead.
-	    if [ -w $DEVICE/operstate ] ; then
-	        if [ "`cat $DEVICE/operstate`" = "up" ] ; then
-		    # It's powered on. Switch it off.
-		    ifdown $NET_IF
-	        else
-		    # It's powered off. Switch it on.
-		    ifup $NET_IF
-		    if [ -x /sbin/wpa_cli ] ; then
-			wpa_cli scan
-		    fi
-	        fi
-	    fi
-	fi
+    for NET_IF in $IFACE_NAMES ; do
+        DEVICE=/sys/class/net/$NET_IF
+
+        FOUND=
+        # Yes, that's right... the new interface reverses the truth values.
+        ON=1
+        OFF=0
+        for CONTROL in $DEVICE/phy80211/rfkill*/state $DEVICE/device/rfkill/rfkill*/state; do
+            if [ -w "$CONTROL" ]; then
+                FOUND=1
+
+                if [ "$(cat "$CONTROL")" = "$ON" ] ; then
+                    # It's powered on. Switch it off.
+                    echo -n "$OFF" > "$CONTROL"
+                else
+                    # It's powered off. Switch it on.
+                    echo -n "$ON" > "$CONTROL"
+                fi
+            fi
+        done
+        # it might be safe to assume that a device only supports one
+        # interface at a time; but just in case, we short-circuit
+        # here to avoid toggling the power twice
+        if [ -n "$FOUND" ]; then
+            continue
+        fi
+
+        ON=0
+        OFF=1  # 1 for rf_kill, 2 for power/state
+        for CONTROL in $DEVICE/device/rf_kill $DEVICE/device/power/state ; do
+            if [ -w $CONTROL ] ; then
+                # We have a way of controlling the device, lets try
+                if [ "`cat $CONTROL`" = 0 ] ; then
+                    # It's powered on. Switch it off.
+                    if echo -n $OFF > $CONTROL ; then
+                        ifdown "${NET_IF}"
+                        break
+                    else
+                        OFF=2 # for power/state, second time around
+                    fi
+                else
+                    # It's powered off. Switch it on.
+                    if echo -n $ON > $CONTROL ; then
+                        ifup "${NET_IF}"
+                        if [ -x /sbin/wpa_cli ]; then
+                            wpa_cli scan
+                        fi
+                        break
+                    fi
+                fi
+            fi
+        done
+
+        # For madwifi we need to check "operstate" instead.
+        if [ -w $DEVICE/operstate ] ; then
+            if [ "`cat $DEVICE/operstate`" = "up" ] ; then
+                # It's powered on. Switch it off.
+                ifdown $NET_IF
+            else
+                # It's powered off. Switch it on.
+                ifup $NET_IF
+                if [ -x /sbin/wpa_cli ] ; then
+                    wpa_cli scan
+                fi
+            fi
+        fi
      done
  }




Contents of /etc/acpi/asus-wireless.sh:

event=button/wlan WLAN 00000080
action=/etc/acpi/asus-wireless.sh



-- System Information:
Debian Release: squeeze/sid
   APT prefers testing
   APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-2-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages acpi-support depends on:
ii  acpi-support-base             0.130-1    scripts for handling base ACPI eve
ii  acpid                         1.0.10-5   Advanced Configuration and Power I
ii  dmidecode                     2.9-1.1    Dump Desktop Management Interface
ii  finger                        0.17-13    user information lookup program
ii  hdparm                        9.15-1     tune hard disk parameters for high
ii  laptop-detect                 0.13.7     attempt to detect a laptop
ii  libc6                         2.10.2-2   GNU C Library: Shared libraries
ii  lsb-base                      3.2-23     Linux Standard Base 3.2 init scrip
ii  pm-utils                      1.2.6.1-3  utilities and scripts for power ma
ii  powermgmt-base                1.30+nmu1  Common utils and configs for power
ii  x11-xserver-utils             7.5+1      X server utilities

Versions of packages acpi-support recommends:
ii  dbus                          1.2.16-2   simple interprocess messaging syst
ii  hal                           0.5.13-6   Hardware Abstraction Layer
ii  nvclock                       0.8b4-1    Allows you to overclock your nVidi
ii  radeontool                    1.5-5      utility to control ATI Radeon back
ii  toshset                       1.75-1     Access much of the Toshiba laptop

acpi-support suggests no packages.

-- no debconf information
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jakub_adam.vcf
Type: text/x-vcard
Size: 195 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-acpi-devel/attachments/20091221/e7b44047/attachment.vcf>


More information about the Pkg-acpi-devel mailing list