diff -Nru /tmp/FyqHBMjQw2/acpi-support-0.94/asus-wireless.sh /tmp/BqdxvSfvte/acpi-support-0.94sladen1/asus-wireless.sh --- /tmp/FyqHBMjQw2/acpi-support-0.94/asus-wireless.sh 2005-10-01 18:00:40.000000000 +0100 +++ /tmp/BqdxvSfvte/acpi-support-0.94sladen1/asus-wireless.sh 2007-03-26 01:03:55.000000000 +0100 @@ -1,10 +1,10 @@ -#!/bin/bash -# Find and enable/disable wireless devices +#!/bin/sh +# Find and toggle wireless devices on Asus laptops -state=`. /etc/acpi/wireless.sh` +. /usr/share/acpi-support/state-funcs -if [ "$state" = "0" ]; then - echo -n 0 > /proc/acpi/asus/wled -else - echo -n 1 > /proc/acpi/asus/wled -fi +toggleAllWirelessStates; + +# Update the Asus LED to reflect the new status of the wireless +! isAnyWirelessPoweredOn; +setLEDAsusWireless $? diff -Nru /tmp/FyqHBMjQw2/acpi-support-0.94/debian/changelog /tmp/BqdxvSfvte/acpi-support-0.94sladen1/debian/changelog --- /tmp/FyqHBMjQw2/acpi-support-0.94/debian/changelog 2007-03-22 05:01:19.000000000 +0000 +++ /tmp/BqdxvSfvte/acpi-support-0.94sladen1/debian/changelog 2007-03-26 01:07:12.000000000 +0100 @@ -1,3 +1,14 @@ +acpi-support (0.94sladen1) unstable; urgency=low + + * Clean up issues with toggling multiple wireless cards. + - Move variable initiation into loop inside 'wireless.sh' + - Move contents of 'wireless.sh' into lib/state-funcs:toggleAllWirelessState() + - Update '{ibm,tosh,asus}-wireless.sh' to use state-funcs + (Closes: LP #96107) + * Remove spurious 'echo HERE' from lib/state-funcs. D'oh. + + -- Paul Sladen Mon, 26 Mar 2007 01:06:58 +0100 + acpi-support (0.94) feisty; urgency=low * Save and restore values that the kernel does not preserve across diff -Nru /tmp/FyqHBMjQw2/acpi-support-0.94/ibm-wireless.sh /tmp/BqdxvSfvte/acpi-support-0.94sladen1/ibm-wireless.sh --- /tmp/FyqHBMjQw2/acpi-support-0.94/ibm-wireless.sh 2007-03-21 04:22:17.000000000 +0000 +++ /tmp/BqdxvSfvte/acpi-support-0.94sladen1/ibm-wireless.sh 2007-03-26 01:03:49.000000000 +0100 @@ -1,20 +1,22 @@ #!/bin/sh -# Find and enable/disable wireless devices +# Find and toggle wireless of bluetooth devices on ThinkPads -BLUETOOTH=/proc/acpi/ibm/bluetooth +. /usr/share/acpi-support/state-funcs -# Note that this alters the state of the wireless! -wireless_state=`. /etc/acpi/wireless.sh` +BLUETOOTH=/proc/acpi/ibm/bluetooth if [ -r $BLUETOOTH ]; then grep -q disabled $BLUETOOTH bluetooth_state=$? fi +# Note that this always alters the state of the wireless! +toggleAllWirelessStates; + # Sequence is Both on, Bluetooth only, Wireless only, Both off -if [ "$wireless_state" = 0 ]; then +if ! isAnyWirelessPoweredOn; then # Wireless was turned off - if [ -w /proc/acpi/ibm/bluetooth ]; then + if [ -w $BLUETOOTH ]; then if [ "$bluetooth_state" = 0 ]; then echo enable > $BLUETOOTH; else diff -Nru /tmp/FyqHBMjQw2/acpi-support-0.94/lib/state-funcs /tmp/BqdxvSfvte/acpi-support-0.94sladen1/lib/state-funcs --- /tmp/FyqHBMjQw2/acpi-support-0.94/lib/state-funcs 2007-03-21 04:43:08.000000000 +0000 +++ /tmp/BqdxvSfvte/acpi-support-0.94sladen1/lib/state-funcs 2007-03-26 01:04:09.000000000 +0100 @@ -1,14 +1,14 @@ #!/bin/sh -# Paul Sladen, 2006-03-28 -# Library functions to check status of wireless +# Paul Sladen, 2006-03-28, 2007-03-26 +# Library functions to check/change status of 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 -a -r $DEVICE/device/power/state ] ; then # If any of the wireless devices are turned on then return success if [ "`cat $DEVICE/device/power/state`" -eq 0 ] ; then - echo HERE # Check if 'rf_kill' disagrees if [ -r $DEVICE/device/rf_kill ] ; then if [ "`cat $DEVICE/device/rf_kill`" -eq 0 ] ; then @@ -25,12 +25,47 @@ return 1 } +# Takes no parameters, toggles all wireless devices. +# TODO: Should possible toggle all wireless devices to the state of the first one. +# Attempts to use 'rf_kill' first, and then tries 'power/state', though that +# 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. Check if it's powered on: + 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 + 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 + break + fi + fi + fi + done + fi + done +} + +# Pass '1' to blink suspending LED and '0' to stop LED setLEDThinkpadSuspending() { action=`test "$1" -ne 0 && echo blink || echo off` test -w /proc/acpi/ibm/led && echo -n 7 "$action" > /proc/acpi/ibm/led } +# Pass '1' to light LED and '0' to dark LED setLEDAsusWireless() { action=`test "$1" -ne 0 && echo 1 || echo 0` diff -Nru /tmp/FyqHBMjQw2/acpi-support-0.94/tosh-wireless.sh /tmp/BqdxvSfvte/acpi-support-0.94sladen1/tosh-wireless.sh --- /tmp/FyqHBMjQw2/acpi-support-0.94/tosh-wireless.sh 2005-10-01 18:00:40.000000000 +0100 +++ /tmp/BqdxvSfvte/acpi-support-0.94sladen1/tosh-wireless.sh 2007-03-26 01:03:39.000000000 +0100 @@ -1,10 +1,12 @@ #!/bin/bash # Find and enable/disable wireless devices -state=`. /etc/acpi/wireless.sh` +. /usr/share/acpi-support/state-funcs -if [ "$state" = "0" ]; then - toshset -bluetooth off -else +toggleAllWirelessStates; + +if isAnyWirelessPoweredOn; then toshset -bluetooth on +else + toshset -bluetooth off fi diff -Nru /tmp/FyqHBMjQw2/acpi-support-0.94/wireless.sh /tmp/BqdxvSfvte/acpi-support-0.94sladen1/wireless.sh --- /tmp/FyqHBMjQw2/acpi-support-0.94/wireless.sh 2007-03-21 03:57:02.000000000 +0000 +++ /tmp/BqdxvSfvte/acpi-support-0.94sladen1/wireless.sh 2007-03-26 01:02:30.000000000 +0100 @@ -1,31 +1,6 @@ #!/bin/sh -# Find and enable/disable wireless devices +# Find and toggle wireless device states -ON=0 -OFF=1 # 1 for rf_kill, 2 for power/state +. /usr/share/acpi-support/state-funcs -for DEVICE in /sys/class/net/* ; do - if [ -d $DEVICE/wireless ] ; then - # $DEVICE is a wireless device. Check if it's powered on: - 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 - echo 0 - 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 - echo 1 - break - fi - fi - fi - done - fi -done +toggleWirelessStates;